null / empty json how to check for it and not output?

Since JSON is simply a data format, there really is no way to know which of your data members will be null unless you explicitly check them. You can always refactor your code to make it more compact and easier to read, but you will have to check each item explicitly if you do not know beforehand which will be null and which will contain data.

While I don't know what your code is supposed to do, here is an example of how you might refactor it to make it more compact:

var data = { Name: "John Doe", Age: 25, Address: null, CityState: "Denver, CO" };
for (member in data) {
    if (data[member] != null)
        // Do work here
}

I'm not completely sure of what you want to do... you say that you don't want to pass them on to other functions so I assume you want to delete them:

var data = {a:"!",b:"null", c:null, d:0, e:"", hasOwnProperty:"test"};

var y;
for (var x in data) {
    if ( Object.prototype.hasOwnProperty.call(data,x)) {
        y = data[x];
        if (y==="null" || y===null || y==="" || typeof y === "undefined") {
            delete data[x];
        }

    }
}

The check for hasOwnProperty is to make sure that it isn't some property from the property chain.


Or you could just use the

int data=0;
try{
   data=json.getInt("Data");
}catch(Exception e){
   data=anydefaultdata;
}