Search code examples
jsoneclipsegeojson

Syntax error on token "{", throw expected before this token at JSON file in eclipse


Why the the eclipse IDE tell that the following GeoJSON data has a syntax error ? The file was generated from XML file in GML structure by the website: http://ogre.adc4gis.com/

{
    "type": "FeatureCollection",
    "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
    "features": [
{ "type": "Feature", "properties": { "gml_id": "1", "ogc_fid": 1, "name": "Bordeaux", "id": 124 }, "geometry": { "type": "Point", "coordinates": [ -0.608315, 44.857522 ] } },
{ "type": "Feature", "properties": { "gml_id": "2", "ogc_fid": 2, "name": "Barbezieux", "id": 0 }, "geometry": { "type": "Point", "coordinates": [ -0.021418, 45.477577 ] } }
]
}

The error is "Syntax error on token "{", throw expected before this token", and it occurred in the first line.


Solution

  • cut your code and replace with the following.

    {
       "type":"FeatureCollection",
       "crs":{
          "type":"name",
          "properties":{
             "name":"urn:ogc:def:crs:OGC:1.3:CRS84"
          }
       },
       "features":[
          {
             "type":"Feature",
             "properties":{
                "gml_id":"1",
                "ogc_fid":1,
                "name":"Bordeaux",
                "id":124
             },
             "geometry":{
                "type":"Point",
                "coordinates":[
                   -0.608315,
                   44.857522
                ]
             }
          },
          {
             "type":"Feature",
             "properties":{
                "gml_id":"2",
                "ogc_fid":2,
                "name":"Barbezieux",
                "id":0
             },
             "geometry":{
                "type":"Point",
                "coordinates":[
                   -0.021418,
                   45.477577
                ]
             }
          }
       ]
    }
    

    you missed one curly braces that's why you getting error!!

    Thanks..