javascript - Access element in json having numerical index -
i have following format of json in want asscess 0.4 , kem , 2 , 2000 values seems doesn't have name index how 1 can access in jquery.
when paste following code in json viewer getting numerical index 0.4 , kem , 2
"td": [ { "@attributes": { "class": "odd" }, "span": [ "3", "7" ] }, "0.4", "kem", "24\/04\/2010", "2000", "2", "14000", "good", "buckley", "56.0", "2:05.32", "36.65", "54.5" ] }
first of all, parentheses don't match up; i'm assuming meant have open curly brace @ beginning of code sample.
if so, object containing 1 field, "td". field array. array contains number of items, first of object , rest strings.
so, if want access 1 of strings, have use numeric index or else iterate on array. example:
var myjson = {"td": [ { "@attributes": { "class": "odd" }, "span": [ "3", "7" ] }, "0.4", "kem", "24\/04\/2010", "2000", "2", "14000", "good", "buckley", "56.0", "2:05.32", "36.65", "54.5" ] }; alert (myjson.td[4]); //displays "2000" alert (myjson.td[7]); //displays "good"
Comments
Post a Comment