I am stuck here for two days, trying to read values of JSONobjects stored in JSONArray. I use JSON simple, its not helping out alot! I only can get to the JSONArray elemts that hold the JSONObjects by something like this jsonstring=JSONArrayName.get(indx); but then I cant read values from the JSON object stored in "jsonstring" string Please help!! please find my code below.
ps: I am using $.ajax, I need to store the values received and process/use it in my server
// here is my client side code Login.html
//My servlet code to process json received from client
BufferedReader reader = request.getReader();
StringBuilder myinputholder = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
myinputholder.append(line);
}
Object obj = JSONValue.parse(myinputholder.toString());
JSONArray newjsonarr = (JSONArray) obj;
// JSONObject newjson= (JSONObject) newjsonarr.get(0); // this line causes errors
PrintWriter pw = response.getWriter();
String f = JSONValue.toJSONString(newjsonarr.get(0));// this will give me a json object
// proper format but I cant do anything with the values inside
JSONValue.writeJSONString(f, pw); // this is only for troubleshooting