I have ASP.NET webservice which 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 I tried to parse this response in Android client and I get following JSON Output:
{
"d": {
"__type": "WebService+Person",
"name": "Mark",
"lastname": "Brawn"
}
}
This output seems valid JSON format, but I would like to know how to properly get properties from this output ( name, lastname...).
In android I parsed this output:
JSONObject json = new JSONObject(result);
json.getString("name");
But I get an exception:
07-12 19:07:14.708: W/System.err(21575): org.json.JSONException: No value for name
So actually i would like to get value "name", and "lastname" from this JSON. Any help appriciated.