I have been looking everywhere for an example of how to isolate a null issue.
I'm being sent a Json string and I'm checking for certain values but sometimes the object (colUniqueID) is not present in the Json string.
{
"mitigant": {
"productUnid": "123456789123456789",
"createdDate": "",
"basketNumber": "bb012456",
"shareIndicator": "",
"assetDetails": [
{
"alias": {
"createdDate": {"value": ""},
"assetID": {"value": "1111"},
"assetNumber": {"value": "aaa123456"},
"colUniqueID": {"value": ""}
}
}
]
}
}
String assetNum = collateral.getMitigant().getAssetDetails().get(i).getAlias().getColUniqueID().getValue();
if (assetNum != null) {
//Do something
}
But I get "HTTP JVM: java.lang.NullPointerException" error when I declare the assetNum variable. So it doesn't even get to the "if" statement
Any ideas??
Please help.