Jackson 2.0.0
dotnet add package Jackson --version 2.0.0
NuGet\Install-Package Jackson -Version 2.0.0
<PackageReference Include="Jackson" Version="2.0.0" />
<PackageVersion Include="Jackson" Version="2.0.0" />
<PackageReference Include="Jackson" />
paket add Jackson --version 2.0.0
#r "nuget: Jackson, 2.0.0"
#:package Jackson@2.0.0
#addin nuget:?package=Jackson&version=2.0.0
#tool nuget:?package=Jackson&version=2.0.0
Jackson
A .NET library for JSON parsing built on top of System.Text.Json, offering advanced type discrimination.
Motivation
Handling objects with complex discrimination requirements in JSON deserialization can be difficult. While System.Text.Json supports basic deserialization well, it often requires cumbersome and error-prone custom converters for more complex logic.
This library simplifies the process by providing an easy solution for deserializing JSON data into objects with complex discrimination needs. By extending System.Text.Json's capabilities, it allows developers to seamlessly deserialize JSON, even with intricate discrimination requirements.
With this library, developers can map JSON data to their object models efficiently, without needing extensive custom converter implementations. This results in a simpler and more maintainable deserialization process.
Get Started
Install package from NuGet:
dotnet add package Jackson
Build a parser to map JSON data to .NET types:
using System;
using System.Text.Json;
using System.Text.Json.Nodes;
using Jackson;
public class Type1;
public class Type2;
var json =
"""
[
{ "f1": "type", "f2": "1" },
{ "f1": "type", "f2": "2" },
{ "f1": "1", "f2": "type" },
{ "f1": "2", "f2": "type" },
{ "f1": "dynamic", "f2": [1, 2, 3], "f3": { "f1": "type", "f2": "1" } }
]
""";
var parser = Parser
.Create(JsonSerializerOptions.Default, "f1", "f2")
.Map<Type1>("type", "1")
.Map<Type2>("type", "2")
.Or(
Parser
.Create(JsonSerializerOptions.Default, "f1", "f2")
.Map<Type1>("1", "type")
.Map<Type2>("2", "type")
.Build()
)
.Build();
var node = JsonSerializer.Deserialize<JsonNode>(json);
if (parser.Parse(node) is IEnumerable<object> seq)
{
foreach (object item in seq)
{
Console.WriteLine(item);
}
}
License
This project is licensed under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. |
-
net8.0
- FSharp.Core (>= 8.0.403)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.