Tuesday 5 November 2019

java - How to break the content of JSONArray into new lines

I am trying to break my JSON result into new lines, but finding it difficult to do.
e.g, {"id":"1","student_id":"5013","subject1":"87","subject2":"87","subject3":"56","subject4":"76","subject5":"68","subject6":"58","subject7":"98","subject8":"67","subject9":"88"}


to


    id : 1
student_id : 5013
subject1 : 87
subject2 : 87
...

I tried using


    String[] stringsArray = new String[jArray.length()];
for (int i = 0; i < jArray.length(); i++) {
System.out.println(stringsArray[i] = jObj.getString(i) + "\n");
}

but still giving same result.
Thanks.

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...