{"1":{"food4":{"id":"4","name":"小米粥","x_units":"克","y_units":"大卡","x":"230","y":"105.80000000000001"},"food2":{"id":"2","name":"馒头","x_units":"克","y_units":"大卡","x":"120","y":"265.2"}},"2":{"food1":{"id":"1","name":"米饭","x_units":"克","y_units":"大卡","x":"236","y":"273.76"},"cook3":{"id":"3","name":"番茄炒鸡蛋","x_units":"克","y_units":"大卡","x":"400","y":"293.1024531024531"}},"3":{"food1":{"id":"1","name":"米饭","x_units":"克","y_units":"大卡","x":"311","y":"360.76"},"cook7":{"id":"7","name":"红烧肉","x_units":"克","y_units":"大卡","x":"322","y":"1536.9452682926828"}},"4":{"cook9":{"id":"9","name":"绿豆汤","x_units":"克","y_units":"大卡","x":"590","y":"192.0181818181818"}},"5":{"acti345":{"id":"345","name":"慢跑","x_units":"秒","y_units":"大卡","x":"50","y":"335"},"acti315":{"id":"315","name":"散步","x_units":"秒","y_units":"大卡","x":"70","y":"195.41666666666666"}}}
其中"1": "2": "3": "4": "5": 这几个,最多只到5了。
那使用JS如何来操作啊,也就是得到12345中的每一项数据,求高手帮忙。
------解决方案--------------------
什么意思啊?
- JScript code
alert(data[1].food2.id); //这样不就可以了?
------解决方案--------------------
m={"1":{"food4":{"id":"4","name":"小米粥","x_units":"克","y_units":"大卡","x":"230","y":"105.80000000000001"},"food2":{"id":"2","name":"馒头","x_units":"克","y_units":"大卡","x":"120","y":"265.2"}},"2":{"food1":{"id":"1","name":"米饭","x_units":"克","y_units":"大卡","x":"236","y":"273.76"},"cook3":{"id":"3","name":"番茄炒鸡蛋","x_units":"克","y_units":"大卡","x":"400","y":"293.1024531024531"}},"3":{"food1":{"id":"1","name":"米饭","x_units":"克","y_units":"大卡","x":"311","y":"360.76"},"cook7":{"id":"7","name":"红烧肉","x_units":"克","y_units":"大卡","x":"322","y":"1536.9452682926828"}},"4":{"cook9":{"id":"9","name":"绿豆汤","x_units":"克","y_units":"大卡","x":"590","y":"192.0181818181818"}},"5":{"acti345":{"id":"345","name":"慢跑","x_units":"秒","y_units":"大卡","x":"50","y":"335"},"acti315":{"id":"315","name":"散步","x_units":"秒","y_units":"大卡","x":"70","y":"195.41666666666666"}}}