S
S
Senum2017-06-03 07:13:07
Android
Senum, 2017-06-03 07:13:07

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

2 answer(s)
D
Denis Zagaevsky, 2017-06-03
@zagayevskiy

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.

S
Senum, 2017-06-03
@Senum

1) everything in Json is displayed in the log in 1 line.
2) That is, my method, in principle, is not working ?, can you share the material on this problem?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question