Json.Net 1.0.25

A minimalistic JSON handler library.

Install-Package Json.Net -Version 1.0.25
dotnet add package Json.Net --version 1.0.25
<PackageReference Include="Json.Net" Version="1.0.25" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Json.Net --version 1.0.25
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Json.Net, 1.0.25"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Json.Net as a Cake Addin
#addin nuget:?package=Json.Net&version=1.0.25

// Install Json.Net as a Cake Tool
#tool nuget:?package=Json.Net&version=1.0.25
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Json.Net & Json.Net.Core

A minimalistic JSON handler library.

Json.Net (.NET Standard 2.0) : https://www.nuget.org/packages/Json.Net/

Json.Net.Core (.NET 5.0) : https://www.nuget.org/packages/Json.Net.Core/

Usage instructions

Define a POCO class...

class Pet
{
  public int id;
  public string name;
}

Serialization...

var petJson = JsonNet.Serialize(pet);

Deserialization...

var pet = JsonNet.Deserialize<Pet>(petJson);

You can also define and use custom type converters to control serialization/deserialization.

var dateConverter = 
  new JsonConverter<DateTime>(
    dt => dt.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss", CultureInfo.InvariantCulture),
    s => DateTime.ParseExact(s, "yyyy'-'MM'-'dd'T'HH':'mm':'ss", CultureInfo.InvariantCulture));
  
var petJson = JsonNet.Serialize(pet, dateConverter);

Reference

Name space

using Json.Net;

Methods

string JsonNet.Serialize(object obj, params IJsonConverter[] converters)
Description

Serializes an object to its JSON text representation.

Parameters

obj : Object to be serialized
converters : Custom type converters. Default: empty


void Serialize(object obj, Stream stream, params IJsonConverter[] converters)
Description

Serializes an object to a JSON text stream destination.

Parameters

obj : Object to be serialized
stream : JSON stream
converters : Custom type converters. Default: empty


void Serialize(object obj, TextWriter writer, params IJsonConverter[] converters)
Description

Serializes an object to a JSON text writer destination.

Parameters

obj : Object to be serialized
writer : JSON text writer
converters : Custom type converters. Default: empty

T JsonNet.Deserialize<T>(string json, params IJsonConverter[] converters)
Description

Deserializes an object from a JSON text.

Parameters

T : Deserialized object's type
json : JSON text
converters : Custom converters. Default: empty


T Deserialize<T>(Stream stream, params IJsonConverter[] converters)
Description

Deserializes an object from a JSON text stream source.

Parameters

T : Deserialized object's type
stream : JSON stream
converters : Custom converters. Default: empty


T Deserialize<T>(TextReader reader, params IJsonConverter[] converters)
Description

Deserializes an object from a JSON text reader source.

Parameters

T : Deserialized object's type
reader : JSON text reader
converters : Custom converters. Default: empty


Converter interface

public interface IJsonConverter
{
  Type GetConvertingType();
  string Serializer(object obj);
  object Deserializer(string txt);
}

Json.Net & Json.Net.Core

A minimalistic JSON handler library.

Json.Net (.NET Standard 2.0) : https://www.nuget.org/packages/Json.Net/

Json.Net.Core (.NET 5.0) : https://www.nuget.org/packages/Json.Net.Core/

Usage instructions

Define a POCO class...

class Pet
{
  public int id;
  public string name;
}

Serialization...

var petJson = JsonNet.Serialize(pet);

Deserialization...

var pet = JsonNet.Deserialize<Pet>(petJson);

You can also define and use custom type converters to control serialization/deserialization.

var dateConverter = 
  new JsonConverter<DateTime>(
    dt => dt.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss", CultureInfo.InvariantCulture),
    s => DateTime.ParseExact(s, "yyyy'-'MM'-'dd'T'HH':'mm':'ss", CultureInfo.InvariantCulture));
  
var petJson = JsonNet.Serialize(pet, dateConverter);

Reference

Name space

using Json.Net;

Methods

string JsonNet.Serialize(object obj, params IJsonConverter[] converters)
Description

Serializes an object to its JSON text representation.

Parameters

obj : Object to be serialized
converters : Custom type converters. Default: empty


void Serialize(object obj, Stream stream, params IJsonConverter[] converters)
Description

Serializes an object to a JSON text stream destination.

Parameters

obj : Object to be serialized
stream : JSON stream
converters : Custom type converters. Default: empty


void Serialize(object obj, TextWriter writer, params IJsonConverter[] converters)
Description

Serializes an object to a JSON text writer destination.

Parameters

obj : Object to be serialized
writer : JSON text writer
converters : Custom type converters. Default: empty

T JsonNet.Deserialize<T>(string json, params IJsonConverter[] converters)
Description

Deserializes an object from a JSON text.

Parameters

T : Deserialized object's type
json : JSON text
converters : Custom converters. Default: empty


T Deserialize<T>(Stream stream, params IJsonConverter[] converters)
Description

Deserializes an object from a JSON text stream source.

Parameters

T : Deserialized object's type
stream : JSON stream
converters : Custom converters. Default: empty


T Deserialize<T>(TextReader reader, params IJsonConverter[] converters)
Description

Deserializes an object from a JSON text reader source.

Parameters

T : Deserialized object's type
reader : JSON text reader
converters : Custom converters. Default: empty


Converter interface

public interface IJsonConverter
{
  Type GetConvertingType();
  string Serializer(object obj);
  object Deserializer(string txt);
}

Release Notes

- Added case ignorant deserialization
- Added support for IEnumerable deserialization
- Performance tweaks
- Unsettable property bugfix

  • .NETStandard 2.0

    • No dependencies.

NuGet packages (7)

Showing the top 5 NuGet packages that depend on Json.Net:

Package Downloads
Cryptocurrency.Blockchain
Cryptocurrency.Blockchain is a library for interacting with the Blockchain Data API provided by Blockchain.
CrunchyrollAPI
Description
Griffin.ReportWriter
Griffin Report Writer (C# Custom Library, for internal use only)
XMLAgenteNuget
Libreria para gestionar XML de agentes de Colibri
CsharpGalenWrapper
This is a wrapper around the existing Galen framework for Layout Testing.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.25 14,545 2/20/2021
1.0.24 122 2/20/2021
1.0.23 130,039 6/20/2020
1.0.22 38,293 5/5/2020
1.0.21 8,808 4/25/2020
1.0.18 121,953 11/19/2019
1.0.17 671 11/19/2019
1.0.16 209,861 1/5/2019
1.0.15 1,297 1/5/2019
1.0.14 738 1/5/2019
1.0.13 3,676 12/17/2018
1.0.12 706 12/17/2018
1.0.11 676 12/16/2018
1.0.10 1,468 12/15/2018
1.0.9 2,315 12/13/2018
1.0.8 622 12/13/2018
1.0.7 570 12/13/2018
1.0.6 717 12/12/2018
1.0.5 674 12/12/2018
1.0.4 553 12/12/2018
1.0.3 653 12/12/2018
1.0.1 729 12/12/2018
1.0.0 7,111 12/12/2018