My JSON Object has some empty values ("") So While converting it throws error.
Here's my JSON
{
"Animals": [
{
"id": 6140,
"Name": ""
},
{
"id": 6144,
"Name": "Lion"
}
]
}
My Code:
JsonParser parser=new JsonParser();
JsonArray myarray=parser.parse(json).getAsJsonArray();
I'm getting the error as
com.google.gson.stream.malformedjsonexception
How do I convert the empty string values into null while parsing the JSON object as a JSONArray?
I want the final result to be
[{id=6140, Name=null},{id=6144, Name="Lion"}]