No wrappers

JSON string is decoded directly into coresponding JSON types.

Fast

Quick parser ensures your data will be transformed in a blink of an eye.

Tiny

Library consist of just few classes and compiled binary is about 50 KB in size.

Example

{
	"array": [0, 1, 2],
	"boolean": true,
	"null": null,
	"number": 123,
	"object": {
		"a": "Aloha",
		"c": "Claire",
		"e": "Edward"
	},
	"string": "Hello World"
}

You may process this sample JSON with ease via JsonDynamic:

' we will take advantage of the dynamic casting
Dim json = JsonParser.Decode(input).ToDynamic()

Console.WriteLine(json("null").IsNull) ' True
Console.WriteLine(json("null") = Nothing) ' True
Console.WriteLine(json("array").Count) ' 3
Console.WriteLine(json("array")(1)) ' 1
Console.WriteLine(json("object")("a")) ' Aloha

Try
    json(0)
Catch ex As InvalidCastException
    Console.WriteLine("Oops, not an array.")
End Try

Dynamic approach is just wrapper around standard strongly typed approach. You may obtain same results in example above with this:

' ok, we want to have strong type control
Dim json = JsonParser.Decode(input)

If json IsNot Nothing AndAlso json.IsObject Then
	Dim jsonObject = json.AsObject() ' = casting shortcut via extensions

	Console.WriteLine(jsonObject("null") Is Nothing) ' True
	Console.WriteLine(jsonObject("array").AsArray().Count) ' 3
	Console.WriteLine(jsonObject("array").AsArray()(1)) ' 1
	Console.WriteLine(jsonObject("object").AsObject()("a")) ' Aloha
End If

Or if you like:

Dim json = JsonParser.Decode(input)

If json IsNot Nothing AndAlso json.IsObject Then
	Dim jsonObject = CType(json, JsonObject)

	If jsonObject("null") Is Nothing Then
		Console.WriteLine("True") ' True
	End If

	If jsonObject("array").IsArray Then
		Dim jsonArray = CType(jsonObject("array"), JsonArray)
		Console.WriteLine(jsonArray.Count) ' 3
		Console.WriteLine(jsonArray(1))	' 1
	End If

	If jsonObject("object").IsObject Then
		Dim jsonInnerObject = CType(jsonObject("object"), JsonObject)
		Console.WriteLine(jsonInnerObject("a"))	' Aloha
	End If
End If

Licensing

Jsonie is open source licensed under MIT license and is free for commercial use.


Author

Brought to you by Michal Novák from Dextronet.