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

https://github.com/i-e-b/skinnyjson

Fast flexible json serialiser & deserialiser with support for contract-based workflows
https://github.com/i-e-b/skinnyjson

c-sharp interface-segregation-principle json messaging production-ready serialisation serialization

Last synced: 4 months ago
JSON representation

Fast flexible json serialiser & deserialiser with support for contract-based workflows

Awesome Lists containing this project

README

          

SkinnyJson
==========

* NuGet: https://www.nuget.org/packages/SkinnyJson/
* GitHub: https://github.com/i-e-b/SkinnyJson

SkinnyJson has a simple interface, and handles interface based serialisation better than most other .Net json libraries.
SkinnyJson was designed to handle Event Store messages, and is tuned to
deal with situations where a common interface declaration is available, but the original serialised objects/types are not available.

Things SkinnyJson can do that most .Net serialisers don't
-----------------------------------------------------------

- Decode directly to an interface: `IThing x = Json.Defrost(...)`. You don't need to create a concrete container.
- Serialise to and from static classes: `var jsonStr = Json.Freeze(typeof(MyStatic)); Json.DefrostTo(typeof(MyStatic), jsonStr);`
- Reformat huge documents: `Json.BeautifyStream(fileStreamIn, Encoding.ASCII, fileStrealOutput, Encoding.UTF8);`

Common use cases:
----------

Deserialise a known type:
```csharp
IMyInterface values = Json.Defrost(jsonString);
```

Serialise any object to JSON:
```csharp
string jsonString = Json.Freeze(myObject);
```

Pretty print a JSON string: (there is also a streaming version for very large files)
```csharp
var newString = Json.Beautify(oldString);
```

Create a deep copy of an object:
```csharp
var newObject = Json.Clone(oldObject);
```

Deserialise to a dynamic type for unknown schemas:
```csharp
dynamic obj = Json.DefrostDynamic(jsonString);
Console.WriteLine(obj.MyProperty.MyArray[4].Prop2()); // use `()` to read a value.
var missing = obj.NotHere.child.grandchild(); // results in null. Dynamic does null propagation.

obj.MyProperty.other = "hello"; // can update properties
var updatedJson = Json.Freeze(obj); // and serialise the result
```

Inline editing:
```csharp
string newJson = Json.Edit(oldJson, d => {
d.myProperty.updated = true;
d.info.updates[0].dateTime = DateTime.Now.ToString();
});
```

See the test cases for deeper examples

Originally based on FastJson: https://github.com/mgholam/fastJSON