Serialization
33 bites tagged Serialization — interview questions with model answers, and 60-second explainers.
Rust's Serde: Taming JSON with Types
Serde JSON translates between human-readable JSON text and native Rust structs, acting as a bilingual interpreter for your data. Use it for web APIs or config files.
BasicMessageChannel: A Coded Pipe to Native
A BasicMessageChannel is a raw data pipe between Dart and native code that uses a "codec" to translate objects into binary. Use it for streaming data or custom types not handled by MethodChannel. The footgun is a codec mismatch, which causes runtime crashes.
json_serializable: Automating JSON in Dart
json_serializable is a boilerplate-writing robot for Dart, automatically generating code to convert classes to and from JSON. It's essential for data models in network requests or local storage.
Manual JSON Serialization with fromJson/toJson
Manually map your Dart objects to JSON by writing your own `fromJson` and `toJson` methods. This is ideal for simple data models or quick prototypes where code generation is overkill.
JSON in Dart: Using `dart:convert`
`dart:convert` is Dart's built-in translator for JSON. It turns Dart Maps into JSON strings (`jsonEncode`) for APIs and file storage, and parses JSON strings back into Maps (`jsonDecode`). The footgun: `jsonDecode` returns a generic Map, not your custom class.
JSON: The Lingua Franca of Web APIs
JSON is a universal translator for data, using human-readable text to describe objects and lists. It's the default for web APIs sending data to browsers. The footgun is treating it as a JavaScript object; JSON is a stricter string format.
Retrofit Converters: Speaking Your API's Language
A Retrofit Converter is a translator that turns raw network data into your app's data classes (e.g., JSON to Kotlin objects). You add a converter factory, like for Moshi or Gson, when building your Retrofit instance. The footgun: converter order matters.
Moshi: Modern JSON for Kotlin & Android
Moshi is a modern JSON library that maps JSON strings to your Kotlin/Java objects. It's a translator between API text and your app's data classes, built with Kotlin-first features. The footgun: Kotlin classes require Moshi's codegen or reflection adapter.
Kotlinx.serialization: Kotlin's Native Data Converter
Kotlinx.serialization is Kotlin's native way to convert data classes into formats like JSON. It uses a compiler plugin to automate the process, making it ideal for API calls or saving data.
Get Serialization bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
Open testing — you’ll join as an early tester.