I am using the condition -
if (!obj2.getString("patronCheckoutInfo").equals("null")) {
But it does not work for the case when array got the value.
Eg: Case1- when json got value for "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 but unable to figure out. Any suggestion is welcome. Thanks in advance.
optJSONArray(String name)returns value if it exists or null otherwiseif (!obj2.getString("patronCheckoutInfo") == null)... Becausenullis not a string to check like that...