I am currently working with Java, reading JSON response from a webservice. Till now I have been parsing JSON for a path known in advance. So I am able to make objects and arrays depending on situation.
String jsonText = readAll(br);
JSONObject json = new JSONObject(jsonText);
JSONObject resp = json.getJSONObject("Response");
But now I have a problem. I have to ask user to provide me a path and I have to get the value at that path in JSON response. Path could be incorrect - return error in that case.
Kind of like XPath in XML. Do we have something similar in JSON?
Path could for example look like: /Response/VehicleSearch/Vehicles/Vehicle[2]/Features/Feature[7]/ID
Please excuse me if its a stupid question. Any help is appreciated. Thanks in advance.