Trivial.Json 3.0.0

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

// Install Trivial.Json as a Cake Tool
#tool nuget:?package=Trivial.Json&version=3.0.0

Includes writable JSON DOM and lots of useful JSON converters.

Note: This library/package is also a part of Trivial so no need to install this if you have already installed that.

Add following namespace to your code file to use.

using Trivial.Text;

Writable JSON DOM

You can create a writable JSON DOM including JSON object JsonObject and JSON array JsonArray.

var json = new JsonObject
{
    { "prop-a", 1234 },
    { "prop-b", "opq" },
    { "prop-c", true },
    { "prop-d", new JsonArray { 5678, "rst" } }
};

And you can write to an instance of System.Text.Json.Utf8JsonWriter by WriteTo member method or get the JSON format string by ToString member method.

JSON converters

Includes a lot of useful JSON converters so that you can use System.Text.Json.Serialization.JsonConvertAttribute attribute to use for member properties of the model.

Following are date time related.

  • JsonJavaScriptTicksConverter
  • JsonJavaScriptTicksConverter.NullableConverter
  • JsonJavaScriptTicksConverter.FallbackConverter
  • JsonJavaScriptTicksConverter.FallbackNullableConverter
  • JsonUnixTimestampConverter
  • JsonUnixTimestampConverter.NullableConverter
  • JsonUnixTimestampConverter.FallbackConverter
  • JsonUnixTimestampConverter.FallbackNullableConverter

Following are number related.

  • JsonNumberConverter
  • JsonNumberConverter.NumberStringConverter
  • JsonNumberConverter.StrictConverter

Following are string collection related.

  • JsonStringListConverter
  • JsonStringListConverter.WhiteSpaceSeparatedConverter
  • JsonStringListConverter.CommaSeparatedConverter
  • JsonStringListConverter.SemicolonSeparatedConverter
  • JsonStringListConverter.VerticalBarSeparatedConverter

Following are JsonObject and JsonArray related.

  • JsonObjectConverter

For example.

public class Model
{
    [JsonConverter(typeof(JsonNumberConverter))
    public int Number { get; set; }

    [JsonPropertyName("creation")]
    [JsonConverter(typeof(JsonJavaScriptTicksConverter))
    public DateTime CreationTime { get; set; }

    [JsonConverter(typeof(JsonObjectConverter)]
    public JsonObject Properties { get; set; }
}

Now you can deserialize following JSON.

{
    "number": "1234",
    "creation": 1577628663614,
    "properties": {
        "items": [ 5, 6, 7, "a", "b", "c" ]
        "b": true
    }
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 was computed.  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 Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 is compatible. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.9.0 3,567 12/15/2021
3.6.0 430 12/17/2020
3.0.0 448 5/12/2020