Json
38 bites tagged Json — interview questions with model answers, and 60-second explainers.
Storing Objects in Web Storage: The JSON Step
Web Storage only stores strings. To save complex data like objects, you must first serialize them with `JSON.stringify()`. This is essential for persisting user settings or session info.
NextResponse.json(): The Standard for API Responses in Next.js
NextResponse.json() is the standard way to send JSON from Next.js Route Handlers, like Express's res.json(). Use it in app/api routes to return data; it automatically sets the correct headers.
JSONEncoder: Turning Swift Objects into JSON
JSONEncoder is your app's translator, converting Swift objects into JSON data for APIs. It's the "serialization" half of Codable. Use it to send data to a server or save objects. The footgun: mismatched keys or date formats require configuring the encoder.
JSONDecoder: Turning JSON into Swift Types
JSONDecoder is your translator for turning raw JSON data into native Swift structs or classes. It's the standard way to parse API responses, letting you work with typed, safe objects.
Swift's Codable: Effortless JSON & Data Parsing
Codable is a compiler magic trick that automatically converts Swift objects to and from formats like JSON. It's used constantly for parsing API responses or saving data to disk. The footgun: decoding fails if JSON keys don't exactly match your property names.
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.
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.
Consuming REST APIs: Speaking to Web Services
Think of consuming a REST API like ordering from a menu. You use standard actions (GET, POST) on specific URLs to request or change data. This is how apps fetch user profiles, get weather data, or submit forms. The footgun: Don't ignore HTTP status codes.
W3C Design Tokens: A JSON Standard for Design Systems
The W3C Design Tokens format is a universal translator for your design system's variables. It's a standard JSON structure that lets design tools and codebases speak the same language for colors and spacing.
W3C Design Tokens: A Standard Format for UI Decisions
A standard design token format is a universal translator for your UI's style, defining colors and spacing in a JSON structure any tool can read. It lets design tools and codebases pull from one source of truth.
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 Json bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
Open testing — you’ll join as an early tester.