Answer the question
In order to leave comments, you need to log in
I can not display the result of parsing Json, how to do it right?
[
{
"id": "1",
"temps" : ReadIn,
"climatOut": [
ReadOut,
ReadIn
],
}
]
ReasOut and ReadIn are variables that store 2 lines each.
Tried to reach like this:
@Override
protected void onPostExecute(String strJson ) {
super.onPostExecute(strJson);
// display the entire received json string
Log.d(LOG_TAG, strJson);
try {
JSONArray rootJSON = new JSONArray(new JSONTokener(strJson));
for (int i = 0; i < rootJSON.length(); i++) {
JSONObject o = rootJSON.getJSONObject(i);
Log.d("TAG", o.getString("temps"));
}
} catch (JSONException e) {
e.printStackTrace();
}
}
Previously, I didn’t particularly come across Json, I would figure it out.
Answer the question
In order to leave comments, you need to log in
1) what is displayed in the log?
2) the built-in parser is the neanderial way. Take a normal gson, write an adapter if necessary.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question