-
Notifications
You must be signed in to change notification settings - Fork 40
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
Question: in-C access to de-jsonification? #444
Comments
|
The problems I run into is pulling very large json-structured strings into R and only then converting to an R-native object: the memory consumed grows quickly. Thanks for the reminder about connections, I'll try with |
To read from http you can use a df <- jsonlite::fromJSON(url('https://tidyverse.r-universe.dev/ggplot2/data/diamonds/json')) |
I'm not reading from HTTP, I'm reading an already-in-memory blob, retrieved from redis. One challenge is that often objects are encoded in JSON in redis. The Bottom line, I think my question here is resolved, your reminder about connections pointed me to obj <- charToRaw(jsonlite::toJSON(mtcars))
head(obj)
# [1] 5b 7b 22 6d 70 67
head(jsonlite::fromJSON(rawConnection(obj)), 3)
# mpg cyl disp hp drat wt qsec vs am gear carb
# Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4
# Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4
# Datsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1 Thanks for the discussion! |
FYI, I found that forcing raw objects from redis and then |
That is what I would have guessed. 99% of the work is done not by the json parsing but subsequently in R allocating all these nested lists and vectors to store the data as an R object.
That's over 10 years ago now, I feel very old 👴 |
I think you were younger than me back then, I doubt you've passed me ... |
Is there any ability to do de-jsonification on something in memory that is not an R string?
I'm thinking on this point: richfitz/redux#60
A partner-company I work with is going to be using Redis as a large-scale cache of big-ish data. I'd rather not pay the string-pool-price of pulling the json text into R-space and calling
fromJSON
. Instead, I'd like to be able to do deserialization (JSON-style) in C-space. Is there a way to work on a raw stream? (I recognize it currently accepts a "file", I'm hoping to not require intermediate temp-files.)The text was updated successfully, but these errors were encountered: