Skip to content
A JSON serializer/deserializer library written in pure C#
C# Python Makefile Shell
Branch: master
Clone or download
Latest commit 6befdaa Jul 11, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
Assets
JSON-Schema-Test-Suite @ 8982b0b
Packages
PreProcess
ProjectSettings
StandaloneProject
ci
nunit-transforms @ 4f5cf0e
.gitattributes
.gitignore
.gitmodules
LICENSE_1_0.txt
Makefile
README.md

README.md

VJson 🍣

A JSON serializer/deserializer library written in pure C#.

CircleCI NuGet Badge codecov license

VJson is a JSON serializer/deserializer (with JsonSchema support) library written in pure C#. Supported versions are .NET Framework 3.5 and .NET Standard 1.6 or higher.
This library is developed as a purely C# project, however it also supports that be build with Unity 2018.3.12f1 or higher.

Installation

For standard C# projects

You can use Nuget/VJson.

dotnet add package VJson

For Unity projects

(TODO: Provide unity packages)

Usage example

Serialize/Deserialize

//
// For serialization
//
var serializer = new VJson.JsonSerializer(typeof(int));

// You can get JSON strings,
var json = serializer.Serialize(42);

// OR write json data(UTF-8) to streams directly.
using (var s = new MemoryStream())
{
    serializer.Serialize(s, 42);
}
//
// For deserialization
//
var serializer = new VJson.JsonSerializer(typeof(int));

// You can get Object from strings,
var value = serializer.Deserialize(json);

// OR read json data(UTF-8) from streams directly.
using (var s = new MemoryStream(Encoding.UTF8.GetBytes(json)))
{
    var value = serializer.Deserialize(s);
}

VJson supports serializing/deserializing of some System.Collections(.Generics) classes listed below,

  • List
  • Dictionary<string, T>
  • Array

and user defined classes. For user defined classes, converting only all public fields are supported.

e.g.

class SomeObject
{
    private float _p = 3.14f; // A private field will not be exported.
    public int X;
    public string Y;
}

var obj = new SomeObject {
    X = 10,
    Y = "abab",
},

var serializer = new VJson.JsonSerializer(typeof(SomeObject));
var json = serializer.Serialize(obj);
// > {"X":10,"Y":"abab"}

var v = serializer.Deserialize("{\"X\":10,\"Y\":\"abab\"}");
// > v becomes same as obj.

Attributes

JSON Schema and validation

VJson supports JSON Schema draft7.

(TODO: Write examples)

Attributes

(TODO: Write examples)

Other use cases are available at here.

Tasks

  • Performance tuning

License

Boost Software License - Version 1.0

References

Author

You can’t perform that action at this time.