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 - How to Configure JAXRS and Spring With Annotations -

visual studio - TFS will not accept changes I've made to a Java project -

php - Create image in codeigniter on the fly -