# NOT RUN {
library(jsonlite)
# From a json character string
## good
geojson_lint('{"type": "Point", "coordinates": [-100, 80]}')
json_good <- minify('{"type": "Point", "coordinates": [-100, 80]}')
geojson_lint(json_good)
## bad
geojson_lint('{"type": "Rhombus", "coordinates": [[1, 2], [3, 4], [5, 6]]}')
json_bad <- minify(
'{"type": "Rhombus", "coordinates": [[1, 2], [3, 4], [5, 6]]}')
geojson_lint(json_bad)
# A file
file <- system.file("examples", "zillow_or.geojson", package = "geojsonlint")
geojson_lint(x = as.location(file))
# A URL
url <- "https://raw.githubusercontent.com/glynnbird/usstatesgeojson/master/california.geojson"
geojson_lint(as.location(url))
# toggle whether reason for validation failure is given back
geojson_lint('{ "type": "FeatureCollection" }')
geojson_lint('{ "type": "FeatureCollection" }', inform = TRUE)
# toggle whether to stop with error message
geojson_lint('{ "type": "FeatureCollection" }')
geojson_lint('{ "type": "FeatureCollection" }', inform = TRUE)
if (interactive()) {
geojson_lint('{ "type": "FeatureCollection" }', error = TRUE)
}
# }
Run the code above in your browser using DataLab