How can I check for a key in json, which I am getting as an output from RESTful api How can I check for a key in json, which I am getting as an output from RESTful api json json

How can I check for a key in json, which I am getting as an output from RESTful api


Try replacing :

if(json.has("DISP_NAME")) {

with

if( json.DISP_NAME ) {

Of course, that won't differentiate between a NULL or empty value and a missing value.

To check the field is in the JSON object, just do:

if( json.keySet().contains( 'DISP_NAME' ) ) {