This repository has been migrated to GitHub
The structure of JSON is quite simple. You can read about the language onjson.org.
Each of the JSON constructs can be mapped to a .Net construct as follows:
This JSON structure is implemented in .Net through three classes:
JsonValue class is a container class for all of the JSON types. In order for everything to remain strongly typed, the class exposes a property for each JSON type. To implement the JSON null value, the static member
JsonValue.Null was created.
JsonObject class is implemented as
Dictionary<string, JsonValue>. As such it can be navigated and manipulated as any other dictionary instance would be.
Similarly to the
JsonObject class, the
JsonArray class is implemented as
List<JsonValue>, which can be navigated and manipulated directly as a list instance.
NOTE Because of
JsonArray's inheritance structure, they are fully LINQ-compatible!
Each of these three classes override the
ToString() method to correctly output in a JSON format.
Implicit casts from
bool were created in
JsonValue to simplify coding and readability. Also, comparison operators were overridden for the
JsonValue class. You can read more on these casts and operators on the Usage page.