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

Very large stringified JSON #61

Open
hrdwdmrbl opened this issue Apr 24, 2019 · 3 comments
Open

Very large stringified JSON #61

hrdwdmrbl opened this issue Apr 24, 2019 · 3 comments

Comments

@hrdwdmrbl
Copy link

I'm interesting in parsing very large stringified JSON strings (up to 2GB). I have the string in memory, but the problem I have is that JSON.parse takes too long to do the parsing. So I'm looking at solutions like clarinet to progressively parse. What I'm wondering is whether clarinet blocks while parsing? Does it ever use setImmediate or yield or something like that so that the node event-loop can run something else and then come back to clarinet?

@dscape
Copy link
Owner

dscape commented Apr 24, 2019 via email

@hrdwdmrbl
Copy link
Author

@dscape Because it was the end of the day and I was hoping for an answer before returning to work the next day.

From my investigations though, the answer is that it does block. The likely reason is because the entire stream has been written and so there is no need to wait for more of the stream. So the parser can keep going until the end.

The reason for having the entire string is that the string is coming from socket.io library which AFAIK does not have a streaming-mode. So the entire string is ready for parsing immediately.

So seems like I can either switch to a streaming a streaming websocket library or I can feed clarinet the string in chunks

@dscape
Copy link
Owner

dscape commented Apr 25, 2019 via email

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