arrays - JSON/Javascript object definition -
trying identify type of array, have multidimensional json array pull website, not using keypairs farmiliar with. structure follows. have included 1 array item show it's doing.
"o": { "ah": ["id1", "12", "id2", "32", "id4", "4", "id5, "6"] },
my searches on both javascript , json objects , strings use semi-colon : define key , value.
in end want loop through multiple items , print them out.
to provide more clarification array structure:
{ "outer": { "item1":[ { "c": { "k": 26862, "n": "thename" }, "o": { "ah": ["id1", "0", "id2", "0", "id3", "0.98", "id4", "0.94", "id5", "5", "id6", "-0/0.5"], "ou": ["id7", "3.5", "id8", "3.5", "id9", "1.53", "id10", "0.55", "id11", "3.4", "id12"], "1x2": ["id13", "1.20", "id14", "25.00", "id15", "4.80"] }, "egn":"" } ] }, { "item1":[ { "c": { "k": 26862, "n": "thename" }, "o": { "ah": ["bd1", "0", "bd2", "0", "bd3", "0.98", "bd4", "0.94", "bd5", "0.5", "bd6", "-0.5"], "ou": ["bd7", "3.5", "bd8", "3.5", "bd9", "1.53", "bd10", "0.55", "bd11", "3.4", "bd12"], "1x2": ["bd13", "1.20", "bd14", "25.00", "bd15", "4.80"] }, "egn":"" } ] } }
if wanted bind id specific field e.g. , display value of id 1 in array structure how without keypair value, if array id not standardized can't loop through var = "id"+ i
foreach element?
o
object, ah
array property of o
object. use json.parse()
convert json
string javascript
object, iterate on o.ah
using array.prototype.foreach()
// or obtain json string var obj = json.parse(jsonstr); obj.o.ah.foreach(function(value) { console.log(value); });
Comments
Post a Comment