Projects
About
Serde.NET is a C# port of the popular Serde serialization library for Rust
Developer ToolsMeasured star growth
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalSerde.NET
Serde.NET is a port of the popular serde.rs Rust serialization/deserialization library to .NET.
For an overview, see Overview.
Start by adding the serde NuGet package:
dotnet add package serde
To generate serialization/deserialization info for a type, now do the following:
- Mark the type partial
- Add the
[GenerateSerde]attribute
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);
[GenerateSerde]
partial record SampleClass
{
// automatically includes public properties and fields
public int X { get; init; } = 3;
public string Y = "sample";
}
Explore related projects
Loading…