K
K
Konstantin Kanaev2014-07-20 16:12:02
Java
Konstantin Kanaev, 2014-07-20 16:12:02

How to form complex json in android (java)?

Need to collect json in android app. Collecting a jason like this is not a problem:
{listSettings: {"namePar":"City", "znachPar":["city_name"]} , then there will be other parameters}.
Here you can clearly see from the brackets that json goes, json is nested in it and then an array of city names.
BUT
I need that instead of the nested (second) json there would also be an array, in general, like this:
{listSettings: ["namePar":"City", "znachPar":["city_name"]] , then what will be repeated in the first square brackets, but with different parameters}.
I thought, of course, to make this internal large array through JSONArray, but judging by its methods, this will not work.
I'm asking for some help any ideas and suggestions. Thank you all in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
barkalov, 2014-07-20
@Yoh_Asakura

listSettings: ["namePar":"City", "znachPar":["city_name"]]

The array (listSettings) is a list of values , and you have a list of key-value pairs . You need an object (an associative array).
For example, like this:
or like this, if you absolutely need an array:
listSettings: [ { "namePar" : "City", "znachPar" : "название_города" }, {...}, {...} ]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question