Not able to Parse a Json File

I want to load a GeoJson File that is uploaded on server

var promise = ('');

This condition works fine But I want to Load this GeoJson File locally so I have assigned the Json Code instead a the Server Link to a Variable on which I am neither getting any error but unable to get the O/P as well

var promise = jQuery.parseJSON ('{ "type": "FeatureCollection","crs":{"type": "name","properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84"}},"features": [{"type": "Feature", "properties": {"id": 1},"geometry": {"type": "Polygon", "coordinates": [ [  [  -83.52936044652942, 40.30230752849768], [ -83.52924865349425,  40.30230753872012], [ -83.52924666169983, 40.3021800251207 ], [ -83.52935848418728, 40.302181900418084 ], [ -83.52936044652942, 40.30230752849768]]]}}, ]}');;

Asked: February 25, 2016 by administrator
Posted Under: programming

1 Answers

When in doubt, run it through a linter/formatter: You have an error in the JSON, a comma a few characters from the end:

]]]}}, ]}');
     ^-------TROUBLE MAKER! Or this one is cool! I am neither getting any error

Maybe the surrounding code is swallowing the error. If you take your var promise = jQuery.parseJSON('DODGY_JSON_HERE') code and run it in the console, you'll see the error:

Uncaught SyntaxError: Unexpected token ](…)
   e.extend.parseJSON              @jquery.min.js:2
   (anonymous function)            @VM270:2
   InjectedScript._evaluateOn      @VM268:875
   InjectedScript._evaluateAndWrap @VM268:808
   InjectedScript.evaluate         @VM268:664
Not as handy as the linter, but at least you see the an error.

Answered: February 25, 2016 by saima01

Post Answer