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

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -