json - JsonPath NoClassDefFoundError, or an alternative to JsonPath in Java -
for reasons related project i'm working on, i'd entire query json file held string, example, $.store.book[*].title
(rather having store each level of document temporarily separate object).
i'm using jsonpath (version 0.8.0, latest find), i'm looking for, i'm getting exception shown below. i'm using sample json given on jsonpath google code page, using 1 of sample queries.
what doing wrong here? alternatively, if there's not solution, there alternatives jsonpath in java? want able pass entire query string, , must in java.
the function:
public void testjsonpath() throws exception { string query = "$.store.book[*].title"; list toret = (list) jsonpath.read(practicejson, query, new filter[0]); system.out.println(toret.tostring()); }
the exception:
java.lang.noclassdeffounderror: net/minidev/json/parser/parseexception @ com.jayway.jsonpath.spi.jsonproviderfactory$1.create(jsonproviderfactory.java:27) @ com.jayway.jsonpath.spi.jsonproviderfactory.createprovider(jsonproviderfactory.java:32) @ com.jayway.jsonpath.jsonpath.read(jsonpath.java:202) @ com.jayway.jsonpath.jsonpath.read(jsonpath.java:307) @ net.windward.datasource.test.testjsondatasource.testjsonpath(testjsondatasource.java:119)
the practice json:
private string practicejson = "{\n" + " \"store\": {\n" + " \"book\": [ {\n" + " \"category\": \"reference\",\n" + " \"author\": \"nigel rees\",\n" + " \"title\": \"sayings of century\",\n" + " \"price\": 8.95\n" + " }, {\n" + " \"category\": \"fiction\",\n" + " \"author\": \"evelyn waugh\",\n" + " \"title\": \"sword of honour\",\n" + " \"price\": 12.99\n" + " }, {\n" + " \"category\": \"fiction\",\n" + " \"author\": \"herman melville\",\n" + " \"title\": \"moby dick\",\n" + " \"isbn\": \"0-553-21311-3\",\n" + " \"price\": 8.99\n" + " }, {\n" + " \"category\": \"fiction\",\n" + " \"author\": \"j. r. r. tolkien\",\n" + " \"title\": \"the lord of rings\",\n" + " \"isbn\": \"0-395-19395-8\",\n" + " \"price\": 22.99\n" + " } ],\n" + " \"bicycle\": [ {\n" + " \"color\": \"red\",\n" + " \"price\": 19.95,\n" + " \"style\": [ \"city\", \"hybrid\" ]\n" + " }, {\n" + " \"color\": \"blue\",\n" + " \"price\": 59.91,\n" + " \"style\": [ \"downhill\", \"freeride\" ]\n" + " } ]\n" + " }\n" + "}";
i think have add these dependencies project: https://code.google.com/p/json-path/downloads/detail?name=json-path-0.8.0-dependencies.zip&can=2&q=
in particular json-smart-1.1.jar missing exception class contained.
Comments
Post a Comment