Skip to content

Decompress gz JSON without JSON.parse #77

Answered by 101arrowz
jimmykane asked this question in Q&A
Discussion options

You must be logged in to vote

First I want to make sure you've verified that high memory usage is actually a problem. JSON strings are almost always less memory-intensive than the JS object they represent, i.e. '{"a": "1234"}' actually costs way less memory than the JS object {a: "1234"} because object keys and strings are UTF-16 in JavaScript, while most JSON data is UTF-8. After parsing the JSON string, it should be garbage collected (if not, you might be able to use an inner scope to force it).

If this is actually a problem, you will need to use a parser built in JavaScript. As for streaming, I'm not sure how useful that would be, given that the entire point is to reduce memory usage but you will need the full obje…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jimmykane
Comment options

Answer selected by jimmykane
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants