knitr::opts_chunk$set( comment = "#>", collapse = TRUE, warning = FALSE, message = FALSE )
GeoJSON linters available in geojsonlint
geojson_hint()
- currently using geojsonhint
v1.2.1
geojson_validate()
Both functions return the same outputs. If the GeoJSON is valid, they return TRUE
.
If the GeoJSON is invalid, they return FALSE
, plus reason(s) that the GeoJSON is invalid
in an attribute named errors as a data.frame. The fields in the data.frame's are not
the same across functions unfortunately, but they can be easily coerced to combine via
e.g., plyr::rbind.fill
or dplyr::bind_rows
or data.table::rbindlist(fill = TRUE)
The parameters for the three functions are similar, though geojson_validate()
has an
extra parameter greedy
that's not available in the others.
from CRAN
install.packages("geojsonlint")
Dev version
remotes::install_github("ropensci/geojsonlint")
library("geojsonlint")
geojsonhint JS library
geojson_hint(x = '{"type": "Point", "coordinates": [-100, 80]}')
is-my-json-valid JS library
geojson_validate(x = '{"type": "Point", "coordinates": [-100, 80]}')
geojsonhint JS library
geojson_hint('{"type": "FooBar"}')
is-my-json-valid JS library
geojson_validate('{ "type": "FeatureCollection" }')
geojsonhint JS library
geojson_hint('{"type": "FooBar"}', inform = TRUE)
is-my-json-valid JS library
geojson_validate('{ "type": "FeatureCollection" }', inform = TRUE)
geojsonhint JS library
geojson_hint('{"type": "FooBar"}', error = TRUE) #> Error: Line 1 #> - The type FooBar is unknown
is-my-json-valid JS library
geojson_validate('{ "type": "FeatureCollection" }', error = TRUE) #> Error: 1 error validating json: #> - data: no (or more than one) schemas match
geojsonlint
in R doing citation(package = 'geojsonlint')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.