Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/serdedotnet/serde
Serde.NET is a C# port of the popular Serde serialization library for Rust
https://github.com/serdedotnet/serde
aot csharp serialization
Last synced: 2 days ago
JSON representation
Serde.NET is a C# port of the popular Serde serialization library for Rust
- Host: GitHub
- URL: https://github.com/serdedotnet/serde
- Owner: serdedotnet
- License: bsd-3-clause
- Created: 2021-03-23T03:36:08.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-16T22:38:35.000Z (25 days ago)
- Last Synced: 2024-11-02T17:03:22.422Z (8 days ago)
- Topics: aot, csharp, serialization
- Language: C#
- Homepage: https://serdedotnet.github.io/
- Size: 2.22 MB
- Stars: 154
- Watchers: 7
- Forks: 6
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- RSCG_Examples - SerdeDn
README
# Serde.NET
Serde.NET is a port of the popular [serde.rs](https://serde.rs) Rust ***ser***ialization/***de***serialization
library to .NET.For an overview, see [Overview](https://serdedotnet.github.io/overview.html).
Start by adding the `serde` NuGet package:
```bash
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`!```csharp
using Serde;
using Serde.Json;string output = JsonSerializer.Serialize(new SampleClass());
// prints: {"X":3,"Y":"sample"}
Console.WriteLine(output);var deserialized = JsonSerializer.Deserialize(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";
}
```