minimaljson.net is a Json parser written in C# which works for DotNetFramework v2.0 or later. It is based on the minimaljson parser from the eclipse opensource project and a very good explanation can be found here. Besides some modifications the use and syntax is the same.
Reading is buffered already, so you don't need to wrap your reader in a BufferedReader.
JsonObject jsonObject = JsonObject.readFrom(string);
JsonArray jsonArray = JsonArray.readFrom(reader);
string name = jsonObject.get("name").asString();
int age = jsonObject.get("age").asInt(); // asLong(), asFloat(), asDouble(), ...
// or iterate over the members:
foreach(JsonObject.Member member in jsonObject)
{
string name = member.name;
JsonValue value = member.value;
// ...
}
String name = jsonArray.get(0).asString();
int age = jsonArray.get(1).asInt(); // asLong(), asFloat(), asDouble(), ...
// or iterate over the values:
foreach(JsonValue value in jsonArray)
{
// ...
}
JsonObject jsonObject = new JsonObject().add("name", "John").add("age", 23);
JsonArray jsonArray = new JsonArray().add("John").add( 23 );
jsonObject.writeTo(writer);
jsonArray.writeTo(writer);
jsonObject.toString();
jsonArray.toString();
You can download a compiled version of this framework here.
The code is available under the terms of the Eclipse Public License.