Result of JSON only containing 1 data
This is the function to check whether if the JSON is array.
i put this function in main.js, so it became global and can be called from any other javascript files

function isArray(obj) {
return Object.prototype.toString.call(obj) === '[object Array]';
}

the return value will be true if the JSON is an Array and it will return false if the json  which is checked is not an array

How to call isArray function from other javascript files :

isArray(response.result.deviceList);

if we give a variable to store the return value :
temp=isArray(response.result.deviceList);
then, temp value will be true or false after isArray function called.
0 Responses

Posting Komentar