JSON loop - get field values not field names

المشرف العام

Administrator
طاقم الإدارة
I'm running a for loop to extract certain values from a JSON string. I get the related values back for a map service that is initiated by the user clicking on a table of contents - e.g. a url, layer etc that is added to a map. But I also have a field object in JSON that has the field value names e.g.

"name": "Service name", "owner": "Owner name", "owner_url": "http://www.blabla.co.uk/", "owner_logo": "http://www.blabla/_images/logo.gif", "url": "http://blabla/arcgis/services/ MapServer", "legend_url": "http://blabla/MapServer/WMSServer?service=WMS&request=GetLegendGraphic&version=1.3.0&format=image%2Fpng&width=200&layer=1", "layer": "0","field": [ "LOCATION_DESCRIPTION", "URL" ]Rather than return the actual names of the values e.g. "LOCATION_DESCRIPTION" I want to call the actual field values from the service - how can I do this. An example of my for loop is:

for (index in jsonString.Recreation) { //alert('Index of for loop ' + index); if (jsonString.Recreation[index].id == myID) { var layerURL = jsonString.Recreation[index].url; var layerids = jsonString.Recreation[index].layer; var fields = jsonString.Recreation[index].field; //alert('LayerURL or record ' + layerURL + layerids); addLayertoMap(layerURL, layerids) //debugger; }Any help would be much appreciated??



أكثر...
 
أعلى