I have to parse a json whom a field can be empty:
{"fullField":"ok","canBeEmpty":""}
if I try to parse this string overall parsing fails with a “no value for canBeEmpty”.
For each json item I execute:
json_data.getString("field"); //throws exception if empty
I’d like to still keep the parsing, setting the canBeEmpty value to a default string…is it possibile?
you can use JSONObject.JSONObject(String name) to check if any name is exist or not in json object as: