validate and sanity-check geojson files
jsonlint-lines, GeoJSON that is also not valid JSON
can return informative, line-oriented parsing errors.
errors = geojsonhint.hint(string or object)
Lint a file, given as a string or object. This call detects all aberrations from the GeoJSON standards and returns them as an array of errors. An example of the output:
Note that the GeoJSON can be given as a string or as an object. Here's how to choose which input to use:
stringinputs receive line numbers for each error. These make errors easier to track down if the GeoJSON is hand-written.
objectinputs don't have line numbers but are evaluated faster, by up to 10x. GeoJSONHint is very fast already so unless you have identified it as a bottleneck in your application, don't prematurely optimize based on this fact.
as a library
npm install --save geojsonhint
as a web library
curl https://raw.github.com/mapbox/geojsonhint/master/geojsonhint.js > geojsonhint.js
npm install -g geojsonhint
➟ geojsonhintUsage: geojsonhint FILE.geojsonOptions:--json output json-formatted data for hints
➟ geojsonhint test.geojsonline 9, each element in a position must be a number
Building the browser version:
npm install -g browserify make