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
Add ArrayStreamJsonDecoder method to http4s-circe #4736
Add ArrayStreamJsonDecoder method to http4s-circe #4736
Conversation
CirceInstances Also add test case for said method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice start. Thank you for adding this! A couple comments below.
@@ -140,6 +141,26 @@ class CirceSuite extends JawnDecodeSupportSuite[Json] { | |||
writeToString(jsons).assertEquals("""[{"test1":"CirceSupport"},{"test2":"CirceSupport"}]""") | |||
} | |||
|
|||
test("stream json array decoder should decode JSON") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good.
What are the semantics if we have a stream that's ill-formed JSON? I think we would return a successful stream that fails? Otherwise, we're back to buffering to see if it's going to fail before we start streaming. It would be neat to make this behavior clear with a test, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the semantics if we have a stream that's ill-formed JSON?
I... didn't think about that for some reason. I'll check and add a test case for it. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, the IO blows up like this on malformed json:
==> X org.http4s.circe.test.CirceSuite.stream json array decoder should fail on malformed JSON 0.028s org.typelevel.jawn.ParseException: expected json value got 'C...' (line 1, column 36)
// stack trace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By "successful stream that fails," I mean you get a DecodeResult
that's a success that's a stream. But compiling that stream will raise the error. That's what's happening?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you get a DecodeResult that's a success that's a stream. But compiling that stream will raise the error
I pondered upon this for a while. That seems to be the case, yes. I added a few test cases, let me know if I got it right.
Co-authored-by: Ross A. Baker <ross@rossabaker.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. We'll have to wait for the Bintray Brownout to finish before CI will work again.
@rossabaker thanks for the guidance and the opportunity to contribute! I'll be on the lookout for more things I could meaningfully contribute. |
Add
streamJsonArrayDecoder
counterpart tostreamJsonArrayEncoder
methods inCirceInstances
.It delegates to byteArrayParser method in circe-fs2.