androidjsongetstring

Json: JSONException: No value for UserNm


I have a problem with the extraction of data from a JSON file that I receive from a PHP file

This is the filecontents of the JSON file I get:

{"success":1,"message":"Data of the Person", "0":{"Name":"Marco","Surname":"Rossi","Age":"32"}}

I tried to use the getString function but it gives me the error JSONException: No value for lane_prodoct

This is an excerpt of the function I use to recover my data:

success = jObj.getString("success");
UserNm = jObj.getString("Name");
UserSrm = jObj.getString("Surname");
UserAge= jObj.getString("Age");


Solution

  • The JSON

    {"success":1,"message":"Data of the Person", "0":{"Name":"Marco","Surname":"Rossi","Age":"32"}
    

    here the last } is missing. It should be like

    {"success":1,"message":"Data of the Person", "0":{"Name":"Marco","Surname":"Rossi","Age":"32"}}