如何遍历任何数字Id的json结构

时间:2017-03-21 10:25:44

标签: javascript json


    {
      "123": {
        "question": "Alert Me When Redmi 3S Available jan-18th 12 noon on FLIPKART.",
        "answer": [
          "Battery is removable or non-removable?",
          "NON-REMOVABLE ..... but powerful battery..."
        ]
      },
      "124": {
        "question": "Can we use Jio SIM in this phone?",
        "answer": [
          "Yeah of course\n",
          "I don't think so it supports Jio sim card"
        ]
      },
      "125": {
        "question": "Is MI note 4 supports 4G?",
        "answer": [
          "Yeah of course\n",
          "I don't think so it supports Jio sim card"
        ]
      }
    }

1 个答案:

答案 0 :(得分:2)

你可以尝试这个例子:

var jsonVar = /* Your JSON */;
for (id in jsonVar) {
    console.log(jsonVarp[id]);
}