i'm getting many json objects through web service , @ times json object malformed.
i wanted check if json valid before processing it.
so worte
jsonelement jsondata = parser.parse(attacheddataattribute); if(jsondata.isjsonobject()) { //then process } not throwing com.google.gson.stream.malformedjsonexception: unterminated string @ line 1 column 8432 @ parse method.
is there implemenation available check json's validity.
that's validation. no need call service.
if method throwing malformedjsonexception it's malformed json.
if want can wrap in method like
public boolean isvalidjson(string json) { try { // parse json return true; } catch(malformedjsonexception e) { return false; } }
Comments
Post a Comment