Blockbuster is a multiplatform library to build Kotlin serialization deserializers that use callbacks. This can be used for example when deserializing large JSON files.
- Can delegate to standard
@Serializable/KSerializerdeserializers. - Multiplatform support: JVM, Android, iOS, Javascript and Native.
Kotlin serialization does not natively support deserializing huge files.
There is Json.decodeToSequence but that is only useful when
the JSON is just a plain array, and is completely specific to the JVM.
Blockbuster supports deserializing complex structures, where the parts specified are lazily deserialized.
val deserializer: DeserializationStrategy<Unit> = buildDeserializer {
field("description") { description: Text -> showText(description) }
objectField("table") {
arrayField("columnNames") { name: String -> addColumnName(name) }
arrayField("rows") { row: Row -> processRow(row) }
}
}
Json.decodeFromStream(deserializer, FileInputStream("huge-table.json"))
Blockbuster is released under the terms of the MIT license.