I'm having trouble parsing some JSON in a java application.
The JSON format is as follows:
{"values": [["kevin", "a value"], ["another name", "another value"]], "cols":["name", "val"]}
My code to parse it this ("results" contains the raw JSON string):
JSONObject myobj = new JSONObject(results);
JSONArray json = myobj.getJSONArray("values");
for(int i = 0; i < json.length(); i++){
JSONArray tmpArr = json.getJSONObject(i).getJSONArray("values");
for(int j = 0; j < tmpArr.length(); j++){
System.out.println(tmpArr.getJSONObject(j).toString());
}
}
This is giving me a JSON typeMismatch error.
My end goal is to be able to use this JSON method that I'm used to working with to get individual values out of my data:
jsonObject.getString("name");
Where name would be the column/attribute name specified in the "cols" in the JSON string.
Any help is very much appreciated.