https://github.com/jsonyte/jsonyte
A System.Text.Json serializer and deserializer for the JSON:API specification.
https://github.com/jsonyte/jsonyte
dotnet json-api
Last synced: 5 months ago
JSON representation
A System.Text.Json serializer and deserializer for the JSON:API specification.
- Host: GitHub
- URL: https://github.com/jsonyte/jsonyte
- Owner: jsonyte
- License: mit
- Created: 2019-06-19T13:28:37.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2025-08-01T09:49:39.000Z (11 months ago)
- Last Synced: 2025-08-16T03:34:15.296Z (10 months ago)
- Topics: dotnet, json-api
- Language: C#
- Homepage:
- Size: 374 KB
- Stars: 7
- Watchers: 2
- Forks: 2
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Jsonyte
[](https://github.com/jsonyte/jsonyte/wiki) [](https://www.nuget.org/packages/Jsonyte) [](https://github.com/jsonyte/jsonyte/discussions) [](https://github.com/jsonyte/jsonyte/blob/master/LICENSE)
A high-performance library for serializing and deserializing [JSON:API](https://jsonapi.org) documents using `System.Text.Json`.
Jsonyte aims to be:
- 🏃 Lightning-fast, as much as **3-5x faster** than other JSON:API serializers for .NET
- 🤝 Simple to setup and easy to use with existing code models
- 🏗️ Easily integrated with ASP.NET Core
- ☑️ Fully compliant with the JSON:API `v1.0` specification (`v1.1` support coming soon)
## Usage
Install the package from NuGet with `dotnet add package Jsonyte`.
```csharp
var options = new JsonSerializerOptions();
options.AddJsonApi();
var json = JsonSerializer.Serialize(new Article(), options);
var article = JsonSerializer.Deserialize(json, options);
```
For an ASP.NET Core application, simply add the following to the startup:
```csharp
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services
.AddControllers()
.AddJsonOptions(x => x.JsonSerializerOptions.AddJsonApi());
}
}
```
## Quick start
Jsonyte will serialize and deserialize plain C# objects to and from the [JSON:API](https://jsonapi.org) format.
For example, the below model will serialize and deserialize the corresponding JSON:API document:
```csharp
public class Article
{
public string Id { get; set; } = "1";
public string Type { get; set; } = "articles";
public string Title { get; set; } = "JSON:API";
}
```
```json
{
"data": {
"type": "articles",
"id": "1",
"attributes": {
"title": "JSON:API"
}
}
}
```
You can also specify your resource type using attributes:
```csharp
[JsonApiResource("articles")]
public class Article
{
public string Id { get; set; } = "1";
public string Title { get; set; } = "JSON:API";
}
```
## Documentation
See the [wiki](https://github.com/jsonyte/jsonyte/wiki) for examples and help using Jsonyte.
## Get in touch
Discuss with us on [Discussions](https://github.com/jsonyte/jsonyte/discussions), or raise an [issue](https://github.com/jsonyte/jsonyte/issues).
[](https://github.com/jsonyte/jsonyte/discussions)
## Contributing
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to this project.
## Acknowledgements
Inspired by the excellent [JsonApiSerializer](https://github.com/codecutout/JsonApiSerializer)
## License
Jsonyte is released under the [MIT License](LICENSE)