我是 Java 开发人员,但在 Jquery 中有一个小任务。我必须解析 Json 数据.... JSON 数据如下:
[
{"category":"Soups","menu_item":"Tomato Soup","type":"veg"},
{"category":"Starters","menu_item":"Summer Salad","type":"veg"},
{"category":"Main Course","menu_item":"Black Beans Chicken","type":"non-veg"},
{"category":"Soups","menu_item":"Lentil Soup","type":"veg"},
{"category":"Starters","menu_item":"Roasted Root Veg","type":"veg"},
]
我正在尝试这段代码,但我没有得到预期的结果......我正在尝试获取 div 中的标签,但不知道我得到的只是......
[对象对象] [对象对象] [对象对象] [对象对象] [对象对象] [对象对象] [对象对象] [对象对象] [对象对象] [对象对象] [对象对象]
我使用的代码是......
$.getJSON("data.json",function(result){
$.each(result, function(i, field){
$("div").append(field + " ");
});
});