Skip to content

Serde-dn is a C# port of the populer Serde serialization library for Rust

License

Notifications You must be signed in to change notification settings

Smallthing/serde-dn

 
 

Repository files navigation

Serde-dn

Serde-dn is a port of the popular serde.rs Rust serialization/deserialization library to .NET.

For an overview, see Overview.

Start by adding the serde-dn NuGet package:

dotnet add package serde --prerelease

You can now use the [GenerateSerialize] and [GenerateDeserialize] attributes to automatically implement serialization and deserialization for your own types. Don't forget to mark them partial!

using Serde;
using Serde.Json;

string output = JsonSerializer.Serialize(new SampleClass());

// prints: {"X":3,"Y":"sample"}
Console.WriteLine(output);

var deserialized = JsonSerializer.Deserialize<SampleClass>(output);

// prints SampleClass { X = 3, Y = sample }
Console.WriteLine(deserialized);

[GenerateSerialize, GenerateDeserialize]
partial record SampleClass
{
    // automatically includes public properties and fields
    public int X { get; init; } = 3;
    public string Y = "sample";
}

About

Serde-dn is a C# port of the populer Serde serialization library for Rust

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 99.8%
  • Other 0.2%