-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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 support for JSON streams to Kotlin Serialization #32074
Conversation
@rotilho Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@rotilho Thank you for signing the Contributor License Agreement! |
Hi, thanks for this PR. As mentioned in #30398, we are waiting for the resolution of Kotlin/kotlinx.serialization#253 to have this feature properly supported, including support for infinite streams. Am I correct in understanding that your PR does not support infinite streams and may block the thread when processing big collections? If that's the case, I think I will decline since I prefer not giving the impression we support streams at programming level if we don't not properly support infinite streams and parsing big check of data without blocking. |
Hey @sdeleuze! I saw that you mentioned the dependency on Kotlin/kotlinx.serialization#253; however, after talking with @sandwwraith and after taking a closer look, I didn't find these limitations. Maybe I'm just missing something obvious, but the current implementation of kotlinx-serialization already supports decoding and encoding to stream. I considered changing the current implementation to use it, but since this is my first contribution, I was afraid to be too adventurous. Answering your questions, the current implementation works with infinite streams, and I don't see any blocking occurring but I'll do more tests. Edit: under load the coroutines just suspend, as expected. |
Indeed, after a deeper look, we should be fine, and the new line delimitation ensures we have properly formed JSON object for each element. |
Merged and polished, thanks for your contribution! |
Closes #30398