-2

From the server I get a string with exactly the following format:

[{"valueOne", "341", "valueTwo": "1432"}, {"valueOne", "6483", "valueTwo": "3267"}]

I understand that it is two JSONObject into an array, but .. Howparse this?

My intention is to have all the concatenated string values, like this:

Strings values = (341 + 1432 + 6483 + 3267);

I guess I must first convert the string that I have received from the server to JSONObject, but do not know how to continue.

In this example there are two JSONObjects, but sometimes may contain three or more.

Many times I get values from JSONObjects values, but I have never seen in this case. I searched for information but can not find a solution that is useful to me.

I appreciate the help

greetings!

4
  • which json package are you using? Commented Jun 24, 2015 at 14:36
  • The data you receive from the server is not a valid json. Commented Jun 24, 2015 at 14:37
  • The json is wrong formatted. Commented Jun 24, 2015 at 14:40
  • Oks, duplicated :( Sorry! Commented Jun 24, 2015 at 15:28

1 Answer 1

0
JsonArray jArray= <your parsed array>;

for(int i=0;i<=jArray.lenght()-1;i++)
{
  String valueOne=jArray.getJsonObject(i).getString("ValueOne");
  String valueTwo=jArray.getJsonObject(i).getString("ValueTwo");
}

you can do whatever you want with the values.

Sign up to request clarification or add additional context in comments.

1 Comment

you should also specify what packages you are using...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.