ktsu.ToStringJsonConverter 1.0.21

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package ktsu.ToStringJsonConverter --version 1.0.21
                    
NuGet\Install-Package ktsu.ToStringJsonConverter -Version 1.0.21
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ktsu.ToStringJsonConverter" Version="1.0.21" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ktsu.ToStringJsonConverter" Version="1.0.21" />
                    
Directory.Packages.props
<PackageReference Include="ktsu.ToStringJsonConverter" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ktsu.ToStringJsonConverter --version 1.0.21
                    
#r "nuget: ktsu.ToStringJsonConverter, 1.0.21"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=ktsu.ToStringJsonConverter&version=1.0.21
                    
Install as a Cake Addin
#tool nuget:?package=ktsu.ToStringJsonConverter&version=1.0.21
                    
Install as a Cake Tool

ktsu.io.ToStringJsonConverter

Overview

ToStringJsonConverter is a JSON converter factory that simplifies serialization and deserialization of custom types in .NET by leveraging the ToString and FromString methods.

Features

  • Automatically identifies types with a FromString method for custom serialization.
  • Converts objects to and from JSON using their string representation.
  • Supports custom types with static FromString methods.

Installation

Install via NuGet:

dotnet add package ktsu.io.ToStringJsonConverter

Usage

Configure the converter in your JsonSerializerOptions:

var options = new JsonSerializerOptions();
options.Converters.Add(new ToStringJsonConverterFactory());

Example

public class MyType
{
    public string Value { get; set; }
    public static MyType FromString(string value) => new() { Value = value };
    public override string ToString() => Value;
}

var myType = new MyType { Value = "example" };
string json = JsonSerializer.Serialize(myType, options); // "example"
MyType deserialized = JsonSerializer.Deserialize<MyType>(json, options);

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on ktsu.ToStringJsonConverter:

Package Downloads
ktsu.AppDataStorage

Application data management library using JSON serialization to save and load data in the user's app data folder.

ktsu.Schema

Schema

ktsu.PkmnDB

PkmnDB

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.4 253 5/21/2025
1.2.4-pre.17 111 5/20/2025
1.2.4-pre.15 70 5/17/2025
1.2.4-pre.14 129 5/16/2025
1.2.4-pre.13 198 5/15/2025
1.2.4-pre.12 201 5/14/2025
1.2.4-pre.11 197 5/13/2025
1.2.4-pre.10 234 5/12/2025
1.2.4-pre.9 162 5/11/2025
1.2.4-pre.8 107 5/10/2025
1.2.4-pre.7 46 5/9/2025
1.2.4-pre.6 120 5/8/2025
1.2.4-pre.5 119 5/7/2025
1.2.4-pre.4 119 5/6/2025
1.2.4-pre.3 112 5/5/2025
1.2.4-pre.2 123 5/4/2025
1.2.4-pre.1 116 5/4/2025
1.2.3 2,693 5/4/2025
1.2.3-pre.1 50 4/26/2025
1.2.2 583 4/25/2025
1.2.2-pre.1 122 4/4/2025
1.2.1 696 3/30/2025
1.2.0 381 3/30/2025
1.1.1-pre.3 78 3/29/2025
1.1.1-pre.2 458 3/25/2025
1.1.1-pre.1 74 2/18/2025
1.1.0 944 2/17/2025
1.0.49-pre.3 82 2/6/2025
1.0.49-pre.2 66 2/5/2025
1.0.49-pre.1 66 2/5/2025
1.0.48 2,480 12/27/2024
1.0.48-pre.30 68 2/4/2025
1.0.48-pre.29 64 2/3/2025
1.0.48-pre.28 73 2/1/2025
1.0.48-pre.27 65 1/30/2025
1.0.48-pre.26 62 1/28/2025
1.0.48-pre.25 62 1/26/2025
1.0.48-pre.24 64 1/24/2025
1.0.48-pre.23 66 1/22/2025
1.0.48-pre.22 60 1/20/2025
1.0.48-pre.21 57 1/18/2025
1.0.48-pre.20 57 1/16/2025
1.0.48-pre.19 46 1/14/2025
1.0.48-pre.18 54 1/13/2025
1.0.48-pre.17 63 1/11/2025
1.0.48-pre.16 56 1/10/2025
1.0.48-pre.15 58 1/10/2025
1.0.48-pre.14 51 1/8/2025
1.0.48-pre.13 69 1/7/2025
1.0.48-pre.12 71 1/5/2025
1.0.48-pre.11 90 1/3/2025
1.0.48-pre.10 67 1/3/2025
1.0.48-pre.9 69 1/3/2025
1.0.48-pre.8 71 1/3/2025
1.0.48-pre.7 67 1/2/2025
1.0.48-pre.6 90 12/31/2024
1.0.48-pre.5 67 12/30/2024
1.0.48-pre.4 72 12/29/2024
1.0.48-pre.3 58 12/28/2024
1.0.48-pre.2 63 12/27/2024
1.0.48-pre.1 66 12/27/2024
1.0.47-pre.1 67 12/27/2024
1.0.46 289 12/26/2024
1.0.45 101 12/26/2024
1.0.44 98 12/26/2024
1.0.43 95 12/26/2024
1.0.42 105 12/26/2024
1.0.41 117 12/26/2024
1.0.40 97 12/26/2024
1.0.39 104 12/25/2024
1.0.38 254 12/23/2024
1.0.37 261 12/23/2024
1.0.36 94 12/23/2024
1.0.35 124 12/23/2024
1.0.34 323 12/19/2024
1.0.33 245 12/16/2024
1.0.32 335 12/6/2024
1.0.31 275 12/5/2024
1.0.30 149 12/4/2024
1.0.29 250 12/2/2024
1.0.28 117 12/2/2024
1.0.27 137 12/2/2024
1.0.26 181 12/1/2024
1.0.25 182 12/1/2024
1.0.24 153 11/30/2024
1.0.23 115 11/29/2024
1.0.22 203 11/27/2024
1.0.21 176 11/26/2024
1.0.20 195 11/20/2024
1.0.19 312 11/15/2024
1.0.18 185 11/14/2024
1.0.17 172 11/13/2024
1.0.16 420 11/4/2024
1.0.15 179 11/1/2024
1.0.14 592 10/17/2024
1.0.13 397 10/7/2024
1.0.12 156 10/4/2024
1.0.11 319 9/23/2024
1.0.10 141 9/20/2024
1.0.10-pre.1 56 12/27/2024
1.0.9 159 9/19/2024
1.0.8 166 9/19/2024
1.0.7 113 9/19/2024
1.0.6 138 9/19/2024
1.0.5 121 9/18/2024
1.0.4 116 9/18/2024
1.0.3 229 9/18/2024
1.0.2 154 9/18/2024
1.0.1 222 9/14/2024
1.0.0 123 9/14/2024