SerializationHelper 2.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SerializationHelper --version 2.0.0                
NuGet\Install-Package SerializationHelper -Version 2.0.0                
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="SerializationHelper" Version="2.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SerializationHelper --version 2.0.0                
#r "nuget: SerializationHelper, 2.0.0"                
#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.
// Install SerializationHelper as a Cake Addin
#addin nuget:?package=SerializationHelper&version=2.0.0

// Install SerializationHelper as a Cake Tool
#tool nuget:?package=SerializationHelper&version=2.0.0                

<img src="https://github.com/jchristn/SerializationHelper/blob/main/Assets/logo.png?raw=true" data-canonical-src="https://github.com/jchristn/SerializationHelper/blob/main/Assets/logo.png?raw=true" width="128" height="128" />

SerializationHelper

SerializationHelper is a simple wrapper around System.Text.Json to overcome some of the common challenges developers face when using Microsoft's JSON library.

NuGet Version NuGet

Help, Feedback, Contribute

If you have any issues or feedback, please file an issue here in Github. We'd love to have you help by contributing code for new features, optimization to the existing codebase, ideas for future releases, or fixes!

Overview

This project was built to provide a simple interface over System.Text.Json. Let's face it. Migrating from the wonderful Newtonsoft.Json package wasn't as easy as anyone expected. Microsoft's implementation is strong but has strong opinions and doesn't, as of the creation of this library, provide the same level of out-of-the-box experience as the Newtonsoft implementation.

This library is my attempt at trying to make the Microsoft implementation behave in a manner consistent to what I experienced while using the Newtonsoft implementation.

New in v2.0.x

v2.0.x

  • Migrate from a static class
  • Allow users to add their own default JsonSerializerOptions
  • Allow users to add and manage their own default list of JsonConverter objects

Example Project

Refer to the Test project for exercising the library.

using SerializationHelper;

public class Person
{
  public int Id { get; set; }
  public string FirstName { get; set; }
  public string LastName { get; set; }
}

Serializer serializer = new Serializer();

Person p1 = new Person { Id = 10, FirstName = "Joe", LastName = "Smith" };
Console.WriteLine(serializer.SerializeJson(p1, false)); // false = not pretty print
// {"Id":10,"FirstName":"Joe","LastName":"Smith"}

Person p2 = serializer.DeserializeJson<Person>("{\"Id\":10,\"FirstName\":\"Joe\",\"LastName\":\"Smith\"}");
Console.WriteLine(p2.Id + ": " + p2.FirstName + " " + p2.LastName);
// 10: Joe Smith

Add Your Own JsonConverter

using SerializationHelper;

public class MyClassConverter : JsonConverter<MyClass>
{
  ...
}

Serializer serializer = new Serializer();
serializer.DefaultConverters.Add(new MyClassConverter());

Version History

Refer to CHANGELOG.md for version history.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  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. 
.NET Framework net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 is compatible.  net481 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 SerializationHelper:

Package Downloads
PDictionary

PDictionary is a persistent dictionary that stores dictionary contents to a JSON file.

PaigoDotNet

Simple C# library for using Paigo.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.1 71 10/30/2024
2.0.0 193 8/7/2024
1.0.3 82 7/14/2024
1.0.2 196 1/17/2024
1.0.1 219 11/2/2023
1.0.0 156 10/30/2023

Initial release