1

我遇到了从Sencha Touch中的JSON获取 Web 服务响应的问题。

我正在收到来自服务器的响应。

{
   "type": "FeatureCollection",
   "features": [
   {
       "type": "Feature",
       "id": "business_poi_en.1",
       "geometry": {
          "type": "Point",
          "coordinates": [
               28.21962354993591,
               36.452844361147314
          ]
    },
    "geometry_name": "geom",
    "properties": {
       "status": "M",
       "score": 100,
       "side": "R",
       "ref_id": 0,
       "id": null,
       "business_p": "AQUARIOUM",
    }
},
{
   "type": "Feature",
   "id": "business_poi_en.2",
   "geometry": {
      "type": "Point",
      "coordinates": [
         28.225417523605692,
         36.436470953176716
      ]
    },
    "geometry_name": "geom",
    "properties": {
       "status": "M",
       "score": 68.44,
       "match_type": "A",
       "side": "L",
       "ref_id": 0,
       "id": null,
       "business_p": "ZIGOS",
    }
},

.... So On ....

我想从几何标签中获取坐标数据,所以我可以通过这些坐标在地图上显示它。我还想从属性标签中获取business_p的数据,以在地图上显示标题。

但是,我无法从同一个响应中同时获得坐标和 business_p 的两个值。

同时获得价值的任何想法?
任何建议将不胜感激。
请帮助解决这个问题。

提前致谢。

4

1 回答 1

0

您的商店代理的读者应该有正确的rootProperty哪个是两者的共同父级coordinatesbusiness_p。为此,您的响应应包含在这样的顶级标签中

{
  "featureResponse": [
    {
        "type": "FeatureCollection",
        "features": []
    },
    {
        "type": "Feature",
        "features": []
    },
  ]
}

然后你可以像这样定义阅读器:

reader: {
            type: 'json',
            rootProperty: 'featureResponse'
        }

一旦你从这个商店获得记录,你可以去dataor rawchildren 对象来获取所需的数据。

于 2013-03-22T06:32:01.180 回答