如何从json字符串中提取地图?

时间:2018-10-07 11:23:24

标签: javascript jquery json

我有此JSON:SBHJm,/ TF,DJ kmlhsZdsbnmifgkldsf; kbnrfposfj mfgiofsmkv fgopktmfiosadznjeriosdbnmseroidzjbm iosersj IOZ; dknrwfdc iOSRZdfhntfrwaio; dxcmjsterkd0pofg dmfpos mjrsepodhnjsew2gioxhjnmkw2eospjkrepo'd,J-0P] Z [tmhjoe [apwtjmdyt,] - 9op524RMJNW45OEPNHJM53,94-0WPH5S4RTKL4EJR- 903EIK-O0JHYTK2QW] -0MS,UK4Wope0skjdytpof [4r21mwejn9eopwkm5ret-0pyt,k21qom-p [k,tl [] 3q,kwqpmjpogtmpol

[
  [
    {
      "hasTouchScreen": true,
      "hasTelephoneCommunication": true,
      "braceletType": "METALLIC",
      "sexType": "MALE",
      "isWaterproof": true,
      "id": 20,
      "cost": 4200.5,
      "modelName": "casmod-2",
      "manufacturer": "rolex",
      "clockFaceGlassType": "GLASS"
    },
    1
  ],
  [
    {
      "hasTouchScreen": true,
      "hasTelephoneCommunication": true,
      "braceletType": "METALLIC",
      "sexType": "MALE",
      "isWaterproof": true,
      "id": 21,
      "cost": 5200.0,
      "modelName": "casmod-3",
      "manufacturer": "rolex",
      "clockFaceGlassType": "GLASS"
    },
    1
  ],
  [
    {
      "hasTouchScreen": true,
      "hasTelephoneCommunication": true,
      "braceletType": "METALLIC",
      "sexType": "MALE",
      "isWaterproof": true,
      "id": 22,
      "cost": 300.0,
      "modelName": "casmod-4",
      "manufacturer": "rolex",
      "clockFaceGlassType": "GLASS"
    },
    2
  ]
]

如何在JQuery中获取和迭代Map? Map是通过Java中的Gson序列化的。

1 个答案:

答案 0 :(得分:0)

for (let index in map) {...}
jQuery中的

OR

$.each(map, function(index, element) {...});

$.each API docs