Conversation
- JSONStreamParser: push-based streaming parser for JSON Lines and JSON Array modes - JSON Lines: extracts multiple JSON documents from a byte stream using STOP_WHEN_DONE - JSON Array: state machine to parse elements from a large JSON array one by one - Internal buffer with lazy compaction for efficient memory management - JSONIncrementalReader: accumulates chunks for large single-document parsing - StreamingJSONLinesDecoder / StreamingJSONArrayDecoder: Codable-layer streaming decoders - JSONValueStream / DecodingStream: AsyncSequence adapters for async byte streams - AsyncSequence extensions: .jsonValues() and .decode() convenience methods - Document.streamParse: internal API using yyjson_doc_get_read_size for accurate byte counting - 33 new tests covering JSON Lines, JSON Array, incremental, edge cases, and Codable layer - All 755 existing tests pass with zero regressions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add streaming/incremental JSON parsing support to ReerJSON.
New Types
Bottom layer (JSONValue):
JSONStreamParser— push-based streaming parser with two modes:.jsonLines: extract multiple JSON documents from a byte stream (NDJSON/SSE).jsonArray: parse elements from a large JSON array one by one, O(1) memoryJSONIncrementalReader— accumulate chunks for large single-document parsingCodable layer:
StreamingJSONLinesDecoder<T>/StreamingJSONArrayDecoder<T>— typed streaming decodersAsyncSequence adapters:
JSONValueStream/JSONValueByteStream/DecodingStreamAsyncSequence.jsonValues()/.decode()convenience extensionsImplementation
YYJSON_READ_STOP_WHEN_DONE+yyjson_doc_get_read_size()for accurate byte-level buffer management[,,,]and parse each element individuallyTesting
Note on yyjson_incr_* API
yyjson 0.12.0's incremental API (
yyjson_incr_new/read/free) requires all data to be pre-loaded in the buffer —lenonly controls how far each parse step reads. It cannot handle dynamically appended data between reads. Therefore, network streaming usesSTOP_WHEN_DONEinstead.