Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent recursion on "json" objects #76

Open
mmuurr opened this issue Nov 13, 2023 · 1 comment
Open

Prevent recursion on "json" objects #76

mmuurr opened this issue Nov 13, 2023 · 1 comment

Comments

@mmuurr
Copy link

mmuurr commented Nov 13, 2023

It's useful at times to include an already-JSON-encoded object in a new object for JSON-encoding, e.g. to prevent an unneeded decoding step (which can be expensive if performed (m|b|tr)-illions of times):

library(jsonify)
x_json <- read_json_object(from, somewhere)  ## ideally we want to not decode x_json
y_json <- list(foo = "bar", x = x_json) |> to_json()  ## re-encodes x_json as length-one string array :-|

This is doable with {jsonlite} provided:

  1. x_json has class "json"
  2. toJSON(...) includes the argument json_verbatim = TRUE.

This would be a useful addition to {jsonify} ... and I'm happy to take a stab at it with a PR if you're open to the idea.

@dcooley
Copy link
Collaborator

dcooley commented Nov 13, 2023

take a stab at it with a PR if you're open to the idea.

yeah go for it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants