I've below json value in my StringBuilder variable, I want to parse all id key value and store it again in StringBuilder.
{"status":"success","id":"1"}
{"status":"success","id":"2"}
{"status":"success","id":"3"}
{"status":"success","id":"4"}
{"status":"success","id":"5"}
{"status":"success","id":"6"}
Expected output: 1 2 3 4 5 6
How can I parse these value in java?
I tried below option but it doesn't help:
StringBuilder str = new StringBuilder();
str.append(jsonStringValue);
JSONObject jObj = new JSONObject(str);
jObj.getString("id");
Using JSONTokener
JSONTokener t = new JSONTokener(str.toString());
while (t.more()) {
JSONObject o2 = (JSONObject) t.nextValue();
System.out.println(o2.getString("id"));
}
But I'm getting below error message: org.json.JSONException: Missing value at character 128