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"}  


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


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


  JsonDataContext dc = new JsonDataContext(new File("src/test/resources/array_with_documents.json"));
  Table table = dc.getDefaultSchema().getTable(0);
  DataSet dataSet = dc.query().from(table).select("id", "name").where("id").gt(1000).execute();
  while (dataSet.next()) {
   Number id = (Number) dataSet.getRow().getValue(0);
   String name = (String) dataSet.getRow().getValue(1);
   // do something with the names and IDs
  • No labels