当jQuery用方括号括起来时,如何用jQuery读取JSON?

时间:2016-10-11 06:27:35

标签: javascript jquery json

这是我想读的JSON:

[{
    "model": "catalog.product",
    "pk": 2476,
    "fields": {
        "created": "2016-10-04T05:28:48.270Z",
        "updated": "2016-10-04T05:28:48.270Z",
        "name": "Flucloxin 250mg",
        "slug": "flucloxin-250mg-1-09353813995272736",
        "generic": "",
        "power": "",
        "manufacturer": null,
        "sku": "",
        "price": "0.00",
        "old_price": "0.00",
        "is_active": true,
        "unit": "piece",
        "description": null,
        "meta_keywords": "",
        "meta_description": "",
        "category": 1,
        "subcategory": 1,
        "height": null,
        "width": null,
        "image": "",
        "thumbnail": "",
        "dosage": 1,
        "related": []
    }
}]

我已尝试使用$.get$.getJSON等,但我所遵循的示例是从JSON格式中读取,如下所示:

{
  "one": "Singular sensation",
  "two": "Beady little eyes",
  "three": "Little birds pitch by my doorstep"
}

正如您所看到的,这只是一个字典,但我打算在列表中阅读一堆字典。另请注意,在密钥fields下的字典中有一个字典。

我如何阅读上述格式?

0 个答案:

没有答案