Skip to content

Commit

Permalink
Merge pull request #110 from qfes/yyjsonr
Browse files Browse the repository at this point in the history
Use {yyjsonr}
  • Loading branch information
anthonynorth authored Jan 30, 2024
2 parents 4061007 + e02874e commit 47b7fdc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ Imports:
tidyselect,
uuid,
vctrs (>= 0.6),
wk (>= 0.9)
wk (>= 0.9),
yyjsonr
Suggests:
geojsonsf,
knitr,
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Rescalers no longer require `center` to be inside input domain (#103)
- All layers now support geometry vectors which {wk} can read (#104)
- Feature editor accepts geometry vectors which {wk} can read (#105)
- Use {yyjsonr} for faster serialisation (#110)

# rdeck 0.5.2

Expand Down
24 changes: 16 additions & 8 deletions R/json.R
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,8 @@ as_json.layer_data <- function(object, cols, dims, ...) {
compiled <- deckgl_table(data, dims)
compiled$length <- jsonlite::unbox(compiled$length)

# 6-digit precision for all sf cols
compiled$columns <- purrr::map_at(
compiled$columns,
geom_cols,
json_stringify,
digits = 6L
)

# 6-digit precision for all cols
compiled$columns <- yyjsonr_stringify(compiled$columns, digits = 6)
json_stringify(compiled, use_signif = TRUE)
}

Expand Down Expand Up @@ -242,3 +236,17 @@ json_stringify <- function(object,
...
)
}

# experimental yyjsonr serialise
yyjsonr_stringify <- function(object, camel_case = FALSE, ...) {
if (camel_case) {
names(object) <- to_camel_case(names(object))
}

json <- yyjsonr::write_json_str(
object,
list(...)
)

structure(json, class = "json")
}
2 changes: 1 addition & 1 deletion man/wk-geometry.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 47b7fdc

Please sign in to comment.