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

Make JSON parsing more lazy #208

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

Conversation

mikekap
Copy link

@mikekap mikekap commented Aug 8, 2024

This patch does 2 things:

  • Fixes the ability to set *chunk-size* for lazy streams (the binding can now be set around the json/parse-stream call rather than around whatever seq-consumption code you were using).
  • "Fixes" the ability to have a very lazy JSON array-stream that only produces one "message" at a time.

For context on the latter, I have a (weird) protocol that looks like this:

[
{"type": "handshake", "id": 0}
, {"type": "command", "id": 1}
, {"type": "command", "id": 2}
...
]

The issue is the producer of this JSON is fully lazy - i.e. it outputs one , {"type": "blah"} command at a time and "waits" for a response. Cheshire can almost parse this, and with this change it can fully parse this (assuming you set *chunk-size* to 1). The root cause is just an issue with calling nextToken before returning the element in the sequence (those two should be reversed).

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.

1 participant