1
votes

I'm stuck with issue for getting web-service response from JSON in Sencha Touch.

I'm getting response from server.

{
   "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 ....

I want to fetch data for coordinates from geometry tag, so I can display it on map via these coordinates.
I also want to fetch data for business_p from properties tag as displaying title on map.

But, I can't get both of values for coordinates & business_p at same time from same response.

Any idea for getting values at same time ?
Any suggestion will be appreciated.
Please help with this issue.

Thanks in advance.

1
can you post store and model as well ? - SachinGutte
your json objects should be in an array - Neil McGuigan

1 Answers

0
votes

Your Store's proxy's reader should have correct rootProperty which is common parent of both coordinates and business_p. For that your response should be wrapped into a top level tag like this

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

Then you can define reader like this:

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

once you get record from this store, you can go to data or raw children object to fetch required data.