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

StackOverflow https://stackoverflow.com/questions/22321352

  •  12-06-2023
  •  | 
  •  

Вопрос

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.

Это было полезно?

Решение

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

Другие советы

If I add to Eclipse a .js file with a valid json content ;

example

{"oo":"ii"}

Then eclipse report the following error:

Multiple markers at this line
    - Syntax error on token "{", throw expected before this token
    - Syntax error on token "", { expected after this token

Note that a bug is reported on this subject cf. Bugzilla – Bug 427543

in addition, please notice that http://jsonlint.com/ is a free online service that could help to validate and format any json content (maybe there is a way to embed this in Eclipse?)

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top