feat: add readJsonArrayAs for streaming JSON array files#1548
Open
buildingvibes wants to merge 2 commits intozio:series/2.xfrom
Open
feat: add readJsonArrayAs for streaming JSON array files#1548buildingvibes wants to merge 2 commits intozio:series/2.xfrom
buildingvibes wants to merge 2 commits intozio:series/2.xfrom
Conversation
Add readJsonArrayAs methods that read JSON files containing a top-level array and stream each element individually. This complements the existing readJsonLinesAs methods (which handle newline-delimited JSON) by using JsonStreamDelimiter.Array instead of JsonStreamDelimiter.Newline. Methods added for File, Path, String, and URL inputs, following the same pattern as the existing readJsonLinesAs family. Closes zio#1071
…tive The AbstractJsonDecoder and AbstractJsonEncoder classes introduced in v0.9.0 inherit JVM-specific streaming methods from platform-specific traits. Since JS and Native have empty platform-specific traits, MiMa detects these inherited methods as missing when comparing against the JVM-published artifact. Add wildcard exclusions for both inner classes in the JS and Native MiMa filters, consistent with the existing exclusions for JsonDecoderPlatformSpecific and JsonEncoderPlatformSpecific.
Author
|
Hi! Following up on this PR which adds readJsonArrayAs methods (complementing the existing readJsonLinesAs family). All 25+ CI checks pass including the MiMa compatibility check. The implementation is minimal - just 4 new method overloads using JsonStreamDelimiter.Array. Happy to address any feedback! |
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
readJsonArrayAsmethods to thezio.jsonpackage that read JSON files containing a top-level array and stream each element individually.This addresses the use case described in #1071 where users need to read JSON files formatted as arrays (e.g.
[{"id": 1}, {"id": 2}]) in a streaming fashion, getting aZStream[Any, Throwable, A]of each decoded element.Changes
JsonPackagePlatformSpecific.scala: AddedreadJsonArrayAs[A: JsonDecoder]overloads forFile,Path,String, andURLinputs, following the same pattern as the existingreadJsonLinesAsfamily but usingJsonStreamDelimiter.Arrayinstead ofJsonStreamDelimiter.Newline.DecoderPlatformSpecificSpec.scala: Added tests for reading JSON arrays from both file paths and URLs.log.json: Added test resource file containing a JSON array of events.Usage
/claim #1071