An open API service indexing awesome lists of open source software.

https://github.com/phema-team/phema.serialization

Serialization wrappers in unified manner
https://github.com/phema-team/phema.serialization

dependency-injection json messagepack serialization xml

Last synced: 2 months ago
JSON representation

Serialization wrappers in unified manner

Awesome Lists containing this project

README

          

# Phema.Serialization

[![Build Status](https://cloud.drone.io/api/badges/phema-team/Phema.Serialization/status.svg)](https://cloud.drone.io/phema-team/Phema.Serialization)

C# Json, xml, protobuf and messagepack wrappers for `Microsoft.Extensions.DependencyInjection`

## Packages

- [![Nuget](https://img.shields.io/nuget/v/Phema.Serialization.svg)](https://www.nuget.org/packages/Phema.Serialization) `Phema.Serialization`
- [![Nuget](https://img.shields.io/nuget/v/Phema.Serialization.Json.svg)](https://www.nuget.org/packages/Phema.Serialization.Json) `Phema.Serialization.Json` - require netcoreapp3.0
- [![Nuget](https://img.shields.io/nuget/v/Phema.Serialization.MessagePack.svg)](https://www.nuget.org/packages/Phema.Serialization.MessagePack) `Phema.Serialization.MessagePack`
- [![Nuget](https://img.shields.io/nuget/v/Phema.Serialization.NewtonsoftJson.svg)](https://www.nuget.org/packages/Phema.Serialization.NewtonsoftJson) `Phema.Serialization.NewtonsoftJson`
- [![Nuget](https://img.shields.io/nuget/v/Phema.Serialization.Protobuf.svg)](https://www.nuget.org/packages/Phema.Serialization.Protobuf) `Phema.Serialization.Protobuf`
- [![Nuget](https://img.shields.io/nuget/v/Phema.Serialization.Xml.svg)](https://www.nuget.org/packages/Phema.Serialization.Xml) `Phema.Serialization.Xml`

## Usage

```csharp

// Json
services.AddJsonSerializer();

// Newtonsoft.Json
services.AddNewtonsoftJsonSerializer();

// MessagePack
services.AddMessagePackSerializer();

// XML
services.AddXmlSerializer();

// Protobuf
services.AddProtobufSerializer();

// Resolve
var serializer = provider.GetRequiredService();

// Serialize
var serialized = serializer.Serialize(model);

// Deserialize
var deserialized = serializer.Deserialize(serialized);
```