Kotlinx.serialization: Support I/O stream

Created on 30 Aug 2018  Â·  10Comments  Â·  Source: Kotlin/kotlinx.serialization

If I deserialize a json from file system, deserialize method require me full read the file to a string.
Can it support read and write json content from I/O stream, like Gson done?

design question

Most helpful comment

It's planned for 1.1 or 1.2

All 10 comments

We are planning a migration to kotlin multiplatform IO library – https://github.com/Kotlin/kotlinx-io . JSON parser would support both strings and kotlinx.io inputs.

This is quite a bummer because I know for a fact that Android can crash when a very large JSON payload is converted to a String at once.

When can we expect a streaming parse? Thanks.

We indeed face this issue when per persist large json (the apps data) which sometimes triggers OutOfMemory.

We are interested by that one for Spring Framework support, beware that for Spring MVC we typically deal with InputStream / OutputStream while on Spring WebFlux side we typically deal with java.nio.ByteBuffer, potentially in combination with the upcoming JSON streaming support (#1073).

This is quite a bummer because I know for a fact that Android can crash when a very large JSON payload is converted to a String at once.

Yes, this should be considered a stopper for all Android applications.

Any news or roadmap?

It's planned for 1.1 or 1.2

Seems like the feature didn't make into 1.1.0-RC. Currently, it's the only reason why I would not feel confident shipping it in a production app.

Really sad, I was looking forward to this being supported

Could you please add support for that in 1.2 in order to allow Spring to use it in Spring Boot 2.5 ?

Was this page helpful?
0 / 5 - 0 ratings