1

I have a json feed that returns an array of google map points. The issue is that it returns everything as a string. I send icon to a google map script. In the example below you will see SQUARE_PIN. This is a variable not a string and it adds the quotes around it preventing it from rendering the variable. Is there a easy way of fixing this.

{
    "title":false,
    "lat":"44.7930232",
    "lng":"-89.7031784",
    "icon":{
        "path":"SQUARE_PIN",
        "fillColor":"#FF0000",
        "fillOpacity":1,
        "strokeColor":"",
        "strokeWeight":0,
        "micon":"<\/span>"
    }
}
Yogesh Mistry
  • 2,082
  • 15
  • 19
James
  • 702
  • 2
  • 15
  • 39

1 Answers1

3

Let's suppose you have your JSON stored in an object called obj. Also, let's suppose that the variable you intend to use is inside another object, called obj2 (could be window if the variable is global). In this case you can do this:

obj.icon.path = obj2[obj.icon.path];

and then use obj.

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175