I have called a rest api from exsternal system using restTemplate. everything is work fine but when I get null in some of values (in example the footer value is null) it is always give jsonexception error
result api
{
"status": "success",
"data": {
"id": "22",
"organization_id": "33",
"name": "name_isf",
"language": "id",
"header": {
"format": "IMAGE",
"example": "#<Hashie::Mash header_handle=#<Hashie::Array [\"result_pic"]>>"
},
"body": "contenty for body",
"footer": null,
"buttons": [],
"status": "APPROVED",
"category": "PERSONAL_FINANCE_UPDATE"
}
}
every call api exsternal i always catch with jsonobject like below
JSONObject res2 = qontakService.getDetailTemplate();
then i will give that to the controller
JSONObject gabunganResult = new JSONObject();
gabunganResult.put("template", objectMapper.writeValueAsString(getDetail.get()));
gabunganResult.put("templateQontak", res2);
and the result error is
com.fasterxml.jackson.databind.JsonMappingException: Object is null (through reference chain: java.util.HashMap["details"]->net.sf.json.JSONObject["templateQontak"]->net.sf.json.JSONObject["data"]->net.sf.json.JSONObject["footer"]->net.sf.json.JSONNull["empty"])
how do I solve this problem ? thank you