Skip to content

ericvoid/minimaljson.net

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

minimaljson.net

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.

Code Examples

Read JSON from a String or a Reader:

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);

Access the contents of a JSON object:

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;
  // ...
}

Access the contents of a JSON array:

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)
{
  // ...
}

Create JSON objects and arrays:

JsonObject jsonObject = new JsonObject().add("name", "John").add("age", 23);
JsonArray jsonArray = new JsonArray().add("John").add( 23 );

Write JSON to a Writer:

jsonObject.writeTo(writer);
jsonArray.writeTo(writer);

Export JSON as a String:

jsonObject.toString();
jsonArray.toString();

Download

You can download a compiled version of this framework here.

License

The code is available under the terms of the Eclipse Public License.

About

A minimal JSON parser written in C#

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 86.4%
  • HTML 13.6%