JsonBuilder
is a small library that demystify the creation of JSON objects in .NET.
- Lightweight
- Simplicity
- Support .NET & .NET Core frmeworks
Creating JSON objects using JsonBuilder
is quite simple
var obj = new JsonBuilder();
JsonBuilder
lets you to add properties as much as you want using AppendProperty()
method.
var obj = new JsonBuilder();
obj.AppendProperty("name", "Jon");
obj.AppendProperty("age", 22);
The actual result of the above JSON object is:
{
"name: "Jon",
"age": 22
}
JsonBuilder
provides two types of formats:
- Indent This is the default format that format the JSON content with indentation in mind.
{
"name: "Jon",
"age": 22
}
- Minified This is use minification to reduce the size o the JSON content
{"name":"Jon","age":22}
JsonBuilder
provides a static
method called IsValidJson()
to validate JSON content.
var isValid = JsonBuilder.IsValidJson("{{"); // false
var isValid = JsonBuilder.IsValidJson("{name: \"Jon\"}"); // true
JsonBuilder
provides a static
method called MergeJsonObject()
to merge multiple JSON objects into a single JSON object.
var json1 = "{\"name\":\"Jon\"}";
var json2 = "{\"name\":\"Doe\"}";
var jsonResult = JsonBuilder.MargeJsonObjects(JsonFormat.Indent, json1, json2);
The actual result of the above JSON object is:
{
"name: "Jon",
"name": "Doe"
}