Skip to content

❗ This is a read-only mirror of the CRAN R package repository. geojsonlint — Tools for Validating 'GeoJSON'. Homepage: https://github.com/ropensci/geojsonlint (devel) https://docs.ropensci.org/geojsonlint (docs) Report bugs for this package: https://github.com/ropensci/geojsonlint/issues

License

Notifications You must be signed in to change notification settings

cran/geojsonlint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

geojsonlint

cran checks Build Status codecov.io rstudio mirror downloads cran version

GeoJSON linters available in geojsonlint

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.

Installation

from CRAN

install.packages("geojsonlint")

Dev version

remotes::install_github("ropensci/geojsonlint")
library("geojsonlint")

Good GeoJSON

geojsonhint JS library

geojson_hint(x = '{"type": "Point", "coordinates": [-100, 80]}')
#> [1] TRUE

is-my-json-valid JS library

geojson_validate(x = '{"type": "Point", "coordinates": [-100, 80]}')
#> [1] TRUE

Bad GeoJSON

geojsonhint JS library

geojson_hint('{"type": "FooBar"}')
#> [1] FALSE

is-my-json-valid JS library

geojson_validate('{ "type": "FeatureCollection" }')
#> [1] FALSE

Bad GeoJSON - with reason for failure

geojsonhint JS library

geojson_hint('{"type": "FooBar"}', inform = TRUE)
#> [1] FALSE
#> attr(,"errors")
#>   line                    message
#> 1    1 The type FooBar is unknown

is-my-json-valid JS library

geojson_validate('{ "type": "FeatureCollection" }', inform = TRUE)
#> [1] FALSE
#> attr(,"errors")
#>   field                             message
#> 1  data no (or more than one) schemas match

Bad GeoJSON - stop on validation failure

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

Meta

  • Please report any issues or bugs.
  • License: MIT
  • Get citation information for geojsonlint in R doing citation(package = 'geojsonlint')
  • Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

rofooter

About

❗ This is a read-only mirror of the CRAN R package repository. geojsonlint — Tools for Validating 'GeoJSON'. Homepage: https://github.com/ropensci/geojsonlint (devel) https://docs.ropensci.org/geojsonlint (docs) Report bugs for this package: https://github.com/ropensci/geojsonlint/issues

Resources

License

Stars

Watchers

Forks

Packages

No packages published