Skip to content

Commit

Permalink
yyjsonr dataframe to json
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonynorth committed Jan 19, 2024
1 parent 23a2272 commit 23de947
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
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 23de947

Please sign in to comment.