JSON DataContext - MetaModel module for reading JSON files

As of MetaModel version 4.2 there is a module called MetaModel-json that allows you to explore and fire queries on a file containing JSON documents.

JSON documents may be appended together, or formatted in the form of a JSON array. For instance

{"id":1234, "name":"Foo"}
{"id":1235, "name":"Bar"}
{"id":1236, "name":"Baz"}

Or:

[
{"id":1234, "name":"Foo"},
{"id":1235, "name":"Bar"},
{"id":1236, "name":"Baz"}
]

Example

Here's an example code use of a JSON file:

   1 JsonDataContext dc = new JsonDataContext(new File("src/test/resources/array_with_documents.json"));
   2 Table table = dc.getDefaultSchema().getTable(0);
   3 DataSet dataSet = dc.query().from(table).select("id", "name").where("id").gt(1000).execute();
   4 while (dataSet.next()) {
   5   Number id = (Number) dataSet.getRow().getValue(0);
   6   String name = (String) dataSet.getRow().getValue(1);
   7   // do something with the names and IDs
   8 }
   9 dataSet.close();