Clone wiki

jsonij / Home

JSON in Java (JSONiJ) Wiki

Welcome to the main guide for the new version of JSONiJ. JSONiJ is a JSON Parser, JPath Implementation. Its easy to use and it has good performance.


Start here if you have a simple JSON job to do.

Install JSONiJ (Maven)


Install JSONiJ (jar)

Download a release or a snapshot of JSONiJ and add it to your classpath.

Parse JSON String

Parsing a String of JSON is pretty straight forward;

JSON resultJSON = JSON.parse("{\"key\":[1,2.3,0.4,-5,-5.92,0.001E1,-0.045E45,987654321]}");

You can then traverse resultJSON similar to an XML DOM.

Parse JSON File

JSONiJ parses any JSON source wrapped in a and, once again, reading it in is pretty straight forward;


URL file = ClassLoader.class.getResource("/config.json");
JSON resultJSON = JSON.parse(file.openStream());

Pull Values From Parsed JSON

The most basic method to pull values out is using the Value API like the following;


Value jsonArray = resultJSON.get("key");

If you feel a little more adventurous then you can use JPath;


Value jsonArray = JPath.evaluate(resultJSON, "/key");

If you are on the run with JPath then why not just grab what you want, like the 3rd element of the key array;


Value jsonArray = JPath.evaluate(resultJSON, "/key[2]");



I always use low version numbers. Don't be put off by the fact that the version is not 1.X.Y+


Version jsonij-0.4.0

Many changes over a long period.

  • The package has been removed from cc.plural.jsonij to simply jsonij.
  • Simplified the license to MIT.
  • Removed the Marshaller (it will be back somewhere - stay on 0.3.X if you need it).
  • Implement parsing for BSON.
  • JPath and JSON Parsing updates.

Older version notes can be found here.


I am happy to help out with any questions wherever I can. Simply contact me through or raise an issue.