Are there any plans to add a streaming reader/writ...
# serialization
t
Are there any plans to add a streaming reader/writer for JSON? Just like JsonReader/JsonWriter in Gson/Moshi? I'm currently using Moshi (only JsonReader/JsonWriter classes) but am looking for a multiplatform solution for Kotlin/Native.
t
@Dominaezzz thanks, that will definitely improve the performance, but for now I don't think that is needed. I just need a class like the Moshi JsonReader. Of course performance would be better if that issue is fixed, but for now I could just load the entire json into memory (String). Looks like this is the class I need but it is internal so I cannot really use it: https://github.com/Kotlin/kotlinx.serialization/blob/master/runtime/common/src/main/kotlin/kotlinx/serialization/json/internal/JsonReader.kt
s
What problem you're trying to solve? Tokenize JSON? Why do you need such low-level approach? IMO, it is almost always easier to read JSON tree into memory (if it fits, of course) – that's why this class is internal
t
@sandwwraith I need low-level as JSON does not match my Kotlin classes. It handles different devices with different responses which are not completely, but nearly, identical. I can take this into account with low-level parsing. Loading the tree into mem will decrease performance.
I've looked into the (internal) JsonReader class a bit more and it is exactly the class I'm looking for. For now the only solution would be to copy it into my project. Would really like to see this class (and related classes) to become public.