System.out.println(json.getRoot().getValueType() + "(" + json.getRoot().nestedSize() + "): " + json.getRoot().toJSON());
JPathParser jPathParser = new JPathParser();
JPath<?> path1 = jPathParser.parse("/store");
path1.setRecordEvaluateTime(true);
Value value = path1.evaluate(json);
System.out.println(value.getValueType() + "(" + value.nestedSize() + "): " + value.toJSON() + " (in " + path1.getLastEvaluateTime() + " ms)");
JPath<?> path2 = jPathParser.parse("/store/book[-2]");
path2.setRecordEvaluateTime(true);
value = path2.evaluate(json);
System.out.println(value.getValueType() + "--> (" + value.nestedSize() + "): " + value.toJSON() + " (in " + path2.getLastEvaluateTime() + " ms)");
JPath<?> path3 = jPathParser.parse("/store/book[2]/title");
path3.setRecordEvaluateTime(true);
value = path3.evaluate(json);
System.out.println(value.getValueType() + "(" + value.nestedSize() + "): " + value.toJSON() + " (in " + path3.getLastEvaluateTime() + " ms)");
JPath<?> path4 = jPathParser.parse("/store/book[$]/title");
path4.setRecordEvaluateTime(true);
value = path4.evaluate(json);
System.out.println(value.getValueType() + "(" + value.nestedSize() + "): " + value.toJSON() + " (in " + path4.getLastEvaluateTime() + " ms)");
JPath<?> path5 = jPathParser.parse("/store/book[last()-3]/title");
path5.setRecordEvaluateTime(true);
value = path5.evaluate(json);
System.out.println(value.getValueType() + "(" + value.nestedSize() + "): " + value.toJSON() + " (in " + path5.getLastEvaluateTime() + " ms)");
JPath<?> path6 = jPathParser.parse("/store/book[last()-1337]/title");
try {
value = path6.evaluate(json);
}
catch (Exception e) {
System.out.println(e.toString());
}
JPath<?> path7 = JPath.parse("/store/number[$-1337]");
path7.setRecordEvaluateTime(true);
value = path7.evaluate(json);
System.out.println(value.getValueType() + "(" + value.nestedSize() + "): " + value.toJSON() + " (in " + path7.getLastEvaluateTime() + " ms)");
}