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.
#:package ktsu.ToStringJsonConverter@1.0.21
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code 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 (2)

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

Package Downloads
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 410 5/21/2025 1.2.4 is deprecated because it is no longer maintained.
1.2.4-pre.17 134 5/20/2025
1.2.4-pre.15 88 5/17/2025
1.2.4-pre.14 152 5/16/2025
1.2.4-pre.13 225 5/15/2025
1.2.4-pre.12 228 5/14/2025
1.2.4-pre.11 223 5/13/2025
1.2.4-pre.10 253 5/12/2025
1.2.4-pre.9 183 5/11/2025
1.2.4-pre.8 125 5/10/2025
1.2.4-pre.7 66 5/9/2025
1.2.4-pre.6 139 5/8/2025
1.2.4-pre.5 142 5/7/2025
1.2.4-pre.4 142 5/6/2025
1.2.4-pre.3 129 5/5/2025
1.2.4-pre.2 143 5/4/2025
1.2.4-pre.1 135 5/4/2025
1.2.3 3,160 5/4/2025
1.2.3-pre.1 64 4/26/2025
1.2.2 625 4/25/2025
1.2.2-pre.1 142 4/4/2025
1.2.1 726 3/30/2025
1.2.0 405 3/30/2025
1.1.1-pre.3 102 3/29/2025
1.1.1-pre.2 479 3/25/2025
1.1.1-pre.1 92 2/18/2025
1.1.0 1,078 2/17/2025
1.0.49-pre.3 104 2/6/2025
1.0.49-pre.2 89 2/5/2025
1.0.49-pre.1 82 2/5/2025
1.0.48 2,539 12/27/2024
1.0.48-pre.30 83 2/4/2025
1.0.48-pre.29 84 2/3/2025
1.0.48-pre.28 94 2/1/2025
1.0.48-pre.27 86 1/30/2025
1.0.48-pre.26 88 1/28/2025
1.0.48-pre.25 81 1/26/2025
1.0.48-pre.24 80 1/24/2025
1.0.48-pre.23 86 1/22/2025
1.0.48-pre.22 79 1/20/2025
1.0.48-pre.21 79 1/18/2025
1.0.48-pre.20 69 1/16/2025
1.0.48-pre.19 67 1/14/2025
1.0.48-pre.18 76 1/13/2025
1.0.48-pre.17 84 1/11/2025
1.0.48-pre.16 78 1/10/2025
1.0.48-pre.15 79 1/10/2025
1.0.48-pre.14 69 1/8/2025
1.0.48-pre.13 85 1/7/2025
1.0.48-pre.12 95 1/5/2025
1.0.48-pre.11 111 1/3/2025
1.0.48-pre.10 83 1/3/2025
1.0.48-pre.9 86 1/3/2025
1.0.48-pre.8 93 1/3/2025
1.0.48-pre.7 78 1/2/2025
1.0.48-pre.6 108 12/31/2024
1.0.48-pre.5 89 12/30/2024
1.0.48-pre.4 92 12/29/2024
1.0.48-pre.3 76 12/28/2024
1.0.48-pre.2 81 12/27/2024
1.0.48-pre.1 82 12/27/2024
1.0.47-pre.1 88 12/27/2024
1.0.46 317 12/26/2024
1.0.45 120 12/26/2024
1.0.44 109 12/26/2024
1.0.43 107 12/26/2024
1.0.42 115 12/26/2024
1.0.41 139 12/26/2024
1.0.40 108 12/26/2024
1.0.39 115 12/25/2024
1.0.38 292 12/23/2024
1.0.37 277 12/23/2024
1.0.36 106 12/23/2024
1.0.35 145 12/23/2024
1.0.34 371 12/19/2024
1.0.33 259 12/16/2024
1.0.32 354 12/6/2024
1.0.31 296 12/5/2024
1.0.30 172 12/4/2024
1.0.29 275 12/2/2024
1.0.28 138 12/2/2024
1.0.27 166 12/2/2024
1.0.26 220 12/1/2024
1.0.25 207 12/1/2024
1.0.24 180 11/30/2024
1.0.23 137 11/29/2024
1.0.22 233 11/27/2024
1.0.21 199 11/26/2024
1.0.20 210 11/20/2024
1.0.19 341 11/15/2024
1.0.18 209 11/14/2024
1.0.17 192 11/13/2024
1.0.16 465 11/4/2024
1.0.15 201 11/1/2024
1.0.14 613 10/17/2024
1.0.13 430 10/7/2024
1.0.12 181 10/4/2024
1.0.11 350 9/23/2024
1.0.10 162 9/20/2024
1.0.10-pre.1 68 12/27/2024
1.0.9 179 9/19/2024
1.0.8 194 9/19/2024
1.0.7 133 9/19/2024
1.0.6 162 9/19/2024
1.0.5 139 9/18/2024
1.0.4 132 9/18/2024
1.0.3 254 9/18/2024
1.0.2 178 9/18/2024
1.0.1 250 9/14/2024
1.0.0 143 9/14/2024