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
- Host: GitHub
- URL: https://github.com/i-e-b/skinnyjson
- Owner: i-e-b
- License: bsd-3-clause
- Created: 2012-06-28T18:28:30.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2024-10-11T15:46:09.000Z (over 1 year ago)
- Last Synced: 2025-04-22T23:04:13.932Z (about 1 year ago)
- Topics: c-sharp, interface-segregation-principle, json, messaging, production-ready, serialisation, serialization
- Language: C#
- Homepage:
- Size: 1.84 MB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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