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

json #179

Open
moodymudskipper opened this issue May 25, 2023 · 1 comment
Open

json #179

moodymudskipper opened this issue May 25, 2023 · 1 comment
Labels
Milestone

Comments

@moodymudskipper
Copy link
Collaborator

moodymudskipper commented May 25, 2023

Useful for #177 and probably other use cases

define json objects from vectors, lists or data frame so they print prettier, using jsonlite::toJSON()

This would also allow using the data arg of construct().

We should keep the other parameters to provide flexibility re the json format

We might detect from the format if we should use serializeJSON()

A simple way to be to test the round trip fromJSON toJSON (resp with serialize if it has the relevant structure), if it works apply constructor, otherwise fall back to character (current).

@moodymudskipper
Copy link
Collaborator Author

json is actually awkwards because serialisation cares about attribute order while the rest of R, including identical() and waldo::compare() do not. And things like subsetting will shuffle the attribute order: https://twitter.com/antoine_fabri/status/1662909266607366144

In principle we could add to constructors an argument to make sure we keep attributes in order, and serialisation functions in constructors would force it, but in practice this would build very awkward code, so I'm tempted to sweep this one under the rug.

Another solution is to provide the constructor for json but have it default on "atomic" so the user actually has to opt in to use it.

Or we force the list constructor instead of data frame/tibble/data.table for its input

@moodymudskipper moodymudskipper added this to the 0.2 milestone May 28, 2023
@moodymudskipper moodymudskipper modified the milestones: 0.2, backlog Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant