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++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -