How to retrive property values from array of objects in javascript -
[{ "circlemarker": [{ "type": "circle_marker" }, { "latlong": "abc" }] }, { "connector_marker": [{ "type": "icon_marker" }, { "latlong": "pqr" }] }, { "icon_marker": [{ "type": "connector_marker" }, { "latlong": "xyz" }] }]
i want access latlong
values of each marker. how can have access each property in structure.
you can latlong data:
for (var = 0; < obj.length; a++) { var key = object.keys(obj[a])[0]; var latlong = obj[a][key][1]; console.log(latlong)); }
but think data have not correct structure, better solution:
var markers = [{ "name": "circlemarker", "type": "circle_marker" "latlong": "abc" }, { "name": "connector_marker", "type": "icon_marker", "latlong": "pqr" }, { "name": "icon_marker", "type": "connector_marker", "latlong": "xyz" }];
Comments
Post a Comment