Json.Net.Core
1.0.33
dotnet add package Json.Net.Core --version 1.0.33
NuGet\Install-Package Json.Net.Core -Version 1.0.33
<PackageReference Include="Json.Net.Core" Version="1.0.33" />
paket add Json.Net.Core --version 1.0.33
#r "nuget: Json.Net.Core, 1.0.33"
// Install Json.Net.Core as a Cake Addin #addin nuget:?package=Json.Net.Core&version=1.0.33 // Install Json.Net.Core as a Cake Tool #tool nuget:?package=Json.Net.Core&version=1.0.33
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);
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. 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. |
-
net5.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
- Same notes as Json.Net but with latest .NET library support