java - How to parse this JSON in android (returned from .NET webservice) -


i have asp.net webservice return person object in json format. please see following webservice code:

[webmethod] [scriptmethod(responseformat = responseformat.json)] public person person() {      person me = new person();     me.name = "mark";     me.lastname = "brawn";      return me; }   public class person {   public string name;  public string lastname; } 

then tried parse response in android client , following json output:

{ "d": {     "__type": "webservice+person",     "name": "mark",     "lastname": "brawn" } 

}

this output seems valid json format, know how properties output ( name, lastname...).

in android parsed output:

jsonobject json = new jsonobject(result); json.getstring("name"); 

but exception:

07-12 19:07:14.708: w/system.err(21575): org.json.jsonexception: no value name 

so value "name", , "lastname" json. appriciated.

the json object being created "result" parent json object, while "name" in nested json object. try json.getobject("d").getstring("name").


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -