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

add support for json_verbatim #46

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mmuurr
Copy link

@mmuurr mmuurr commented May 7, 2024

This adds support for a json_verbatim boolean flag that functions similarly to {jsonlite}'s equivalent flag, addressing #25.

When an atomic character vector is passed to {yyjsonr}'s serializer, there's now a check to see if that vector (element) inherits from the "json" class. If the element does and the new json_verbatim flag is TRUE, then the raw string (char*) is inserted into the growing yyjson JSON doc as-is.

There is no check for JSON-validity of this string, so it's up to the user to know that such strings are indeed already valid JSON; this is the same here-be-dragons situation as with the fast_numerics flag.

In #25, the OP-proposed flag name was skip_json, but I thought it'd be useful to actually try to replicate {jsonlite}'s API in this instance and stick with json_verbatim, but obviously I defer to @coolbutuseless on naming preferences.

Tests are included to handle some basic cases, which can be used for documentation. If it looks like this'll indeed be merged, I can add another commit adding those docs, but figured I'd wait on those until it looks like this will be merged (since perhaps there'll be some discussion and changes along the way).

@coolbutuseless
Copy link
Owner

Many thanks!

I will add this to the roadmap for the next release.

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

Successfully merging this pull request may close these issues.

None yet

2 participants