Skip to content

JBeet/Blockbuster

Repository files navigation

Blockbuster

Kotlin JVM Android iOS Windows Linux macOS JS WASM

Blockbuster is a multiplatform library to build Kotlin serialization deserializers that use callbacks. This can be used for example when deserializing large JSON files.

Features

  • Can delegate to standard @Serializable/KSerializer deserializers.
  • Multiplatform support: JVM, Android, iOS, Javascript and Native.

Overview

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.

Usage

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"))

License

Blockbuster is released under the terms of the MIT license.

About

Kotlin library to build Deserializers with callbacks (e.g. for deserializing large JSON files)

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors

Languages