Question

I have the following .js file, and Dreamweaver reports a syntax error on line 2.

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "id": 0,
      "properties": {
        "Id": 0,
        "Title": "River & Trail HQ",
        "Other": null,
        "Parking": "Yes"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [
          -8649997.6690437607,
          4769179.73322534
        ]
      }
    }
  ]
}

Seems something is wrong with

"type": "FeatureCollection",

line.

Was it helpful?

Solution

If that's the whole JavaScript file, then it's giving you an error because it's interpreted as a block instead of an object literal. To fix this, you could assign it to something, like

var someObj = {
    "type": "FeatureCollection",
    ...
}

You may also be thinking of a JSON file (which is probably the case, since a free-floating object literal isn't going to do you much good anyway). JSON and JavaScript are not the same. If you really want a JSON file, then save it as such (.json).

OTHER TIPS

Try

var x = {
"type": "FeatureCollection",

"features": [
{ 
    "type": "Feature", "id": 0, "properties": 
    { 
        "Id": 0, "Title": "River & Trail HQ", "Other": null, "Parking": "Yes" 
    }, 
    "geometry": 
    { 
        "type": "Point", "coordinates": [ -8649997.6690437607, 4769179.73322534 ] 
    } 
}
]};

http://jsonlint.com shows it as valid JSON and I can't see any issues with it on visual inspection.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top