json - Javascript: if an array has object or is no empty -
this question has answer here:
- how test empty javascript object? 40 answers
i have json data below:
{ "errorcode": null, "message": "success", "result": { }, "totalrecord": 0, "checkaccess": true, "token": "fb8904acf4dbf0406ac3fd16acd9b84807d2a0e2913aecc3f39e90ca4b53161af6058ca5ee46b9877b75292e5ca9b8df969a325fa3b40c0e4acde546a431f55f6c07de8a854b9e0bf6aeba314d239267" }
in json can find "result"
empty, how can identify if statement? tried use !== "undedined"
, !==null
statment still executes.
if(trend1_data[0].result !== 'undefined'){ var resultone = trend1_data[0].result; var chartval1 = resultone.mention30d.chartvalues; for(var i=0; < chartval1.length; i++){ vol1.push(chartval1[i].value);//a loop generate value array xvol1.push(chartval1[i].date);// xaris values e.g:date } }
result
object inside json array
hope useful
var = [{ "errorcode": null, "message": "success", "result": { }, "totalrecord": 0, "checkaccess": true, "token": "somevalue" } ] alert(object.keys(a[0].result).length)
Comments
Post a Comment