【发布时间】:2012-12-17 00:55:45
【问题描述】:
我有一个从 php 文件返回的 json 对象,如下所示:-
{"food":[
{
"name" :"Belgian Waffles",
"price" :"$5.95",
"description":"two of our famous Belgian Waffles with plenty of real maple syrup",
"calories" :"650"
},
{
"name" :"Strawberry Belgian Waffles",
"price" :"$7.95",
"description":"light Belgian waffles covered with strawberries and whipped cream",
"calories" :"900"
},
{
"name" :"Berry-Berry Belgian Waffles",
"price" :"$8.95",
"description":"light Belgian waffles covered with an assortment of fresh berries and whipped cream",
"calories" :"900"
}
]}
这实质上是从对象返回三个食物元素。如果 json 数据是动态的且使用 jquery 未知,如何计算返回的元素总数?
【问题讨论】:
-
其实有3种食物元素!