android - How to check if json array has any value? -
i using condition -
if (!obj2.getstring("patroncheckoutinfo").equals("null")) {
but not work case when array got value.
eg: case1- when json got value "patroncheckoutinfo":
{ "errormessage": "" "message": "operation completed successfully" "status": "ok" "results": { "lookuppatroninforesponse": { "patronaddressinfo": null "patroncheckouthistoryinfo": null "patroncheckoutinfo": [6] 0: { "author": "cobb, kevin."
case 2 - when no value:
{ "errormessage": "" "message": "operation completed successfully" "status": "ok" "results": { "lookuppatroninforesponse": { "patronaddressinfo": null "patroncheckouthistoryinfo": null "patroncheckoutinfo": null "patroncirculationinfo": null
tried few tutorials unable figure out. suggestion welcome. in advance.
you can use support function isnull
(http://developer.android.com/reference/org/json/jsonobject.html#isnull(java.lang.string))
so, re-write code in case:
if (!obj2.isnull("patroncheckoutinfo")) { // }
Comments
Post a Comment