I
I
ivan8m82016-02-04 16:08:45
Android
ivan8m8, 2016-02-04 16:08:45

How to select data from array info [{...}, {...}, ...]?

Hello.
Using API (JSON response) I get some data.
Everything was successful until I ran into the need to get data from an array.
This array looks like this:

"info": [
      {
       "high": "1",
      },
      {
       "high": "3",
      },
      {
       "high": "2",
      },
     ]

Now, if there highwas one or they would be called by different names, I would get them like this:
myVar = data.optInt("high");where datais JSONObjectin populate.
But since there are several of them, I can't do that.
Tell me, please, how to be?
For example, how can I high1write the first element of the array infointo a variable high2- the second, etc.?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
aol-nnov, 2016-02-04
@aol-nnov

how do you translate jason into objects?
here are some examples

D
Denis Zagaevsky, 2016-02-19
@zagayevskiy

JSONArray array = data.toJSONArray(); //Или data.getJSONArray(String);
array.length();
array.getJSONObject(int);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question