Search code examples
androidandroid-studioandroid-jsonjsonexception

JSONException to parse HTML formatted text


I'm calling a web service from my Android application. The web service returns the following JSON : JSON Image

Now the problem is when I'm trying to get the description element of the record object I'm getting an exception as org.json.JSONException: No value for description

Now my question is how can I get the value of the description using the existing parser without changing the response JSON format.


Solution

  • According to me,

    You are using the wrong object to get description value otherwise org.json.JSONException: No value for description error will not occur.

    Also, check if you can using optString instead of getString which just returns null if value do not exist, instead of throwing an exception.