android - how to parse this json formate using Gson lib -


how parse sub array getstring("sub") using gson lib in android.

<pre> {    "name"  : "abc";   "class" : "xyz";    "address" : {[              "add" : "1";              "sub" :["abc"];           ]}      }   </pre> 

first of should reduce json correct form:

{    "name"  : "abc",    "class" : "xyz",    "address" : [          {"add" : "1",          "sub" :["abc"]}       ] } 

now, create objects following structure:

class foo{    string name;    string class;    address[] address; }  class address{    string add;    string[] sub;  } 

and on step can parse json object, calling line:

foo foo = new gson().fromjson(json, foo.class); 

Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -