Skip to content
tezvyn:

Top 30 Json Interview Questions and Answers

30 multiple-choice questions on Json, drawn from 30 bites out of the 38 tagged Json on Tezvyn. Answer them here or read straight down. Every question carries the correct option, why it is correct, and a link to the bite it came from.

30 questions. Pick an answer, or open “Show the answer” to read it.

Answers are graded in your browser. Nothing is saved, and no XP or streak is earned here. The app keeps score.

  1. Question 1 of 30

    What condition forces V8's JSON.stringify to abandon its new side-effect-free fast path and use the slower recursive serializer?

    Show the answer

    Answer: a · One of the properties defines a custom toJSON method

    Custom toJSON methods execute user code during serialization, violating the side-effect-free guarantee required for the fast path. Deep nesting is actually improved by the iterative fast path, while Unicode strings and null-prototype objects do not inherently trigger the slower recursive serializer.

    Read the full bite: V8 doubles JSON.stringify speed with side-effect-free fast path

  2. Question 2 of 30

    Why is structured logging considered foundational for observability at large scale?

    Show the answer

    Answer: a · Its consistent named fields enable reliable querying, aggregation, and correlation across services

    Structured logs put data in named fields, so you can query, aggregate, and join on trace IDs reliably at volume, which free text cannot. It does not replace metrics or traces, and it favors machine-parseability over raw readability.

    Read the full bite: Structured vs unstructured logging: why it matters

  3. Question 3 of 30

    Which statement accurately describes a semantic difference between a Dart factory constructor and a generative constructor?

    Show the answer

    Answer: c · A factory constructor can return an existing cached instance or a subtype, while a generative constructor always produces a fresh instance of the exact class.

    A factory constructor is not required to create a new instance and may return a cached object or subtype, whereas a generative constructor always allocates a fresh instance of the exact class. Option B is tempting because factories resemble static methods, but they remain part of the constructor namespace and are called with standard constructor syntax.

    Read the full bite: What is a Dart factory constructor and common use cases?

  4. Question 4 of 30

    You need to parse a dynamic JSON array into List<Product> where some objects may contain missing or mistyped fields. Which approach best preserves type safety and prevents runtime crashes?

    Show the answer

    Answer: a · Use a factory constructor that checks runtime types and defaults, then map over the list while isolating or skipping invalid rows.

    Defensive parsing inside a factory constructor centralizes validation and runtime type checks in the model layer, while isolating or skipping invalid rows during mapping prevents one malformed item from crashing the entire list. Option C spreads uncertainty by pushing null handling into the UI, and C fails because a Map cannot be directly cast to a custom class.

    Read the full bite: How do you model Product and safely parse JSON into List<Product>?

  5. Question 5 of 30

    An engineer needs to improve an LLM's structured JSON extraction rate using only prompt changes. Which approach should they prioritize?

    Show the answer

    Answer: d · Include the exact JSON schema with empty values and add one to three valid input-output examples

    Embedding an exact JSON skeleton and providing few-shot exemplars are the two prompt-based techniques that constrain the output distribution by making the desired token sequence highly probable. Chain-of-thought reasoning is a tempting distractor because it often increases verbosity and introduces stray tokens that break JSON validity.

    Read the full bite: Describe two prompt-based techniques to ensure valid LLM JSON output

  6. Question 6 of 30

    Why must you wait for the request's end event before calling JSON.parse on a POST body?

    Show the answer

    Answer: d · The body arrives as multiple chunks and is only complete once end fires

    The request is a stream delivering chunks via data events; the full body exists only after end. The body is not encrypted, JSON.parse works anywhere, and req.body is not natively populated.

    Read the full bite: Reading a POST body from the request stream

  7. Question 7 of 30

    Which approach correctly handles the full response lifecycle when fetching JSON from a REST API in production using Python's requests?

    Show the answer

    Answer: c · Verify the status with r.raise_for_status() before parsing with r.json()

    Calling r.raise_for_status() before r.json() catches HTTP errors like 404 or 500 before parsing fails. Skipping the status check is a major red flag because error responses often do not contain valid JSON, causing r.json() to crash.

    Read the full bite: How do you fetch JSON from a REST API and parse it?

  8. Question 8 of 30

    Why does structured logging scale better than unstructured logging for large-system analysis?

    Show the answer

    Answer: b · Named machine-readable fields can be indexed, filtered, and aggregated reliably instead of parsed with brittle regex

    Structured logs expose explicit fields that backends index and query precisely, enabling reliable filtering, aggregation, and correlation at scale. Free-text logs force fragile regex parsing that breaks as messages change, which does not scale.

    Read the full bite: Structured vs unstructured logging

  9. Question 9 of 30

    When consuming a REST API, what is the primary function of the HTTP status code in the server's response?

    Show the answer

    Answer: a · To inform the client about the outcome of its request, such as success or failure.

    The card explains that the HTTP status code is "the waiter telling you if your order succeeded," directly indicating its role in communicating the success or failure of the request. Other options describe functions handled by HTTP headers or the URL.

    Read the full bite: Consuming REST APIs: Speaking to Web Services

  10. Question 10 of 30

    Where must app.use(express.json()) be registered for req.body to be available in a POST handler?

    Show the answer

    Answer: a · Before the route handlers, so the body is parsed when they run

    Middleware runs in registration order, so the parser must be mounted before the routes to populate req.body in time. Express does not reorder middleware, and registering it after the routes leaves req.body undefined.

    Read the full bite: Parsing JSON bodies with express.json

  11. Question 11 of 30

    When returning data from a JSON API, why is res.json preferred over res.end for sending an object?

    Show the answer

    Answer: d · res.json serializes the object and sets application/json, while res.end does neither

    res.json stringifies the object and sets the JSON content type; res.end sends raw data with no serialization or content-type help. res.end is not deprecated, and res.json does serialize rather than skip it.

    Read the full bite: res.send vs res.json vs res.end

  12. Question 12 of 30

    When configuring fetch inside an async createUser function to POST JSON data, which option correctly serializes the payload and handles the response?

    Show the answer

    Answer: b · body is JSON.stringify(data), Content-Type is application/json, it checks response.ok, and returns await response.json()

    Option B is correct because fetch requires JSON.stringify to serialize the payload and a Content-Type header so the server can parse it, plus it returns the parsed JSON rather than the raw Response. Option C is tempting but wrong because passing the raw object directly causes the body to become the string [object Object], silently breaking the request.

    Read the full bite: Write a createUser function that POSTs JSON via fetch

  13. Question 13 of 30

    You add a CodingKeys enum to remap one JSON key but list only that single property. Why might other properties stop decoding?

    Show the answer

    Answer: c · Declaring CodingKeys replaces the synthesized key set, so any property omitted from the enum is no longer decoded

    Providing a CodingKeys enum overrides the auto-synthesized keys, so every property you want coded must appear in it; omitted ones are skipped. It does not require a custom initializer or a particular decoding strategy.

    Read the full bite: Map JSON keys to differently named Codable properties

  14. Question 14 of 30

    Which statement accurately describes the proper way to parse a JSON list from an HTTP GET response in Dart?

    Show the answer

    Answer: d · Construct a Uri with Uri.parse, await http.get, check that statusCode equals 200, then decode and cast the body to List<Map<String, dynamic>>

    Option D is correct because package:http requires a Uri, verifying statusCode 200 prevents decoding error pages, and casting to List<Map<String, dynamic>> gives the compiler the concrete collection shape. Option C is tempting because it includes the right cast, but passing a raw string is invalid and skipping the status check risks decoding a non-JSON error response.

    Read the full bite: Make a GET request with http and parse JSON in Dart

  15. Question 15 of 30

    When implementing JSON deserialization in a Dart model class, why is a factory constructor typically chosen over a generative constructor?

    Show the answer

    Answer: c · They allow validation and transformation of JSON values before the main constructor handles field assignment.

    A factory constructor centralizes deserialization and lets you preprocess raw JSON values before passing clean data to the primary constructor. The claim that Dart requires a factory for fromJson is a common misconception, since generative constructors can technically parse JSON but lack the same flexibility for arbitrary preprocessing.

    Read the full bite: Purpose of factory fromJson constructor in Dart models

  16. Question 16 of 30

    When evaluating manual JSON serialization against json_serializable for a growing Dart codebase, which trade-off is most accurate?

    Show the answer

    Answer: d · Manual serialization avoids build dependencies but risks boilerplate drift, whereas code generation adds compile-time latency while producing equivalent runtime performance.

    Option D captures the core trade-off: manual methods avoid build steps but become error-prone at scale, while json_serializable introduces build_runner latency but generates plain Dart that performs identically at runtime. Option A is a tempting distractor because many candidates mistakenly believe code generation affects end-user performance, but the card emphasizes runtime is identical.

    Read the full bite: Compare manual JSON serialization versus json_serializable

  17. Question 17 of 30

    When using Swift's Codable protocol, which scenario would typically require custom implementation beyond the default synthesis?

    Show the answer

    Answer: b · The JSON keys do not exactly match the Swift property names.

    Option B is correct because the card explicitly states that the default implementation will fail if JSON keys don't match Swift property names, requiring a custom CodingKeys enum. Option C is incorrect as Codable automatically handles nested Codable types.

    Read the full bite: Swift's Codable: Effortless JSON & Data Parsing

  18. Question 18 of 30

    Which statement accurately contrasts JSON serialization approaches in Go and Rust?

    Show the answer

    Answer: c · Go's standard library includes a reflection-based JSON encoder, while Rust relies on external crates like serde to derive serialization traits at compile time.

    Go ships encoding/json in its standard library and uses runtime reflection, whereas Rust intentionally omits serialization from std and delegates to external crates like serde for compile-time derived traits. Distractor B is tempting because derive macros can look like reflection, but they generate code at compile time rather than inspecting types at runtime.

    Read the full bite: Serialize a Go struct to JSON and contrast with Rust

  19. Question 19 of 30

    Which approach correctly stores and retrieves a typed object in localStorage?

    Show the answer

    Answer: d · Use setItem with JSON.stringify, then getItem, check for null, parse in try-catch, and cast to an interface

    localStorage persists only strings, so you must stringify on write and parse on read, but you must also check for null before parsing because getItem returns null when a key is missing. Option C is tempting because it includes serialization and typing, yet skipping the null check causes a runtime error whenever the key does not exist.

    Read the full bite: How do you store and retrieve a TypeScript object in localStorage?

  20. Question 20 of 30

    Which task is the primary function of JSONDecoder in a Swift application?

    Show the answer

    Answer: b · Transforming raw JSON Data received from an API into structured Swift types.

    The card explicitly states JSONDecoder bridges the gap between unstructured JSON and strongly-typed Swift data, automating the conversion of JSON Data into safe, usable Swift objects. Option D describes the function of JSONEncoder, which performs the opposite task.

    Read the full bite: JSONDecoder: Turning JSON into Swift Types

  21. Question 21 of 30

    Which task is the primary responsibility of JSONEncoder in a Swift application?

    Show the answer

    Answer: a · Converting Swift objects into a standardized JSON format for external use.

    JSONEncoder's fundamental purpose is to serialize Swift objects into JSON data, preparing them for tasks like sending to a server or saving to a file. It does not directly handle network transmission or the reverse process of parsing JSON.

    Read the full bite: JSONEncoder: Turning Swift Objects into JSON

  22. Question 22 of 30

    A JWT is signed with a shared secret but not encrypted. Who can read its JSON payload?

    Show the answer

    Answer: a · Anyone who intercepts the token, though only secret holders can verify its origin

    The card describes a JWT as a readable postcard by default; signing proves authenticity but does not provide confidentiality. Option B is tempting because learners often assume the shared secret that verifies the signature also decrypts the payload, but encryption is a separate, optional step.

    Read the full bite: JWT: Signed JSON Claim Tokens

  23. Question 23 of 30

    What is a key characteristic that distinguishes Kotlinx.serialization from reflection-based serialization libraries?

    Show the answer

    Answer: b · It generates type-safe serialization code during compilation, avoiding runtime reflection.

    Kotlinx.serialization uses a compiler plugin to generate conversion logic at compile time, making it type-safe and performant without relying on runtime reflection. The most tempting distractor suggests it uses reflection, which is precisely what it aims to avoid.

    Read the full bite: Kotlinx.serialization: Kotlin's Native Data Converter

  24. Question 24 of 30

    When handling a POST request in a Next.js App Router Route Handler, which approach correctly extracts the JSON body?

    Show the answer

    Answer: d · Export an async POST function that calls await request.json() and returns a standard Response object.

    Next.js App Router Route Handlers are built on standard Web APIs, so you await request.json() and return a Response object. The Express-style approach is wrong because req.body and res.json() do not exist in this environment.

    Read the full bite: How do you parse JSON body in a POST Route Handler?

  25. Question 25 of 30

    What is the primary benefit of adopting the W3C Design Tokens standard for a UI project?

    Show the answer

    Answer: d · It establishes a single source of truth for UI style values, ensuring consistency across diverse platforms and tools.

    The card highlights that the standard acts as a "universal adapter" and "single source of truth" for style values, bridging design and development to ensure consistency across multiple platforms and tools. Option C is incorrect because it facilitates collaboration and consistent implementation, not the elimination of developer roles.

    Read the full bite: W3C Design Tokens: A Standard Format for UI Decisions

  26. Question 26 of 30

    When using `jsonDecode` from `dart:convert` on a JSON string representing a single object, what is the direct return type?

    Show the answer

    Answer: d · A Map<String, dynamic> containing the JSON data.

    The card states that `jsonDecode` typically results in a `Map<String, dynamic>` for JSON objects. It explicitly mentions that it does not return your custom class directly, which is a common misconception for beginners.

    Read the full bite: JSON in Dart: Using `dart:convert`

  27. Question 27 of 30

    Which of the following is a necessary step for Moshi to properly handle Kotlin data classes?

    Show the answer

    Answer: d · Providing a KotlinJsonAdapterFactory or using moshi-kotlin-codegen.

    Moshi requires either compile-time code generation via moshi-kotlin-codegen or a runtime reflection adapter (KotlinJsonAdapterFactory) to understand Kotlin's specific language features. Without this, it cannot correctly map JSON to Kotlin objects. Forcing all properties to be nullable (Option C) is incorrect; Moshi is designed to handle Kotlin's non-nullability.

    Read the full bite: Moshi: Modern JSON for Kotlin & Android

  28. Question 28 of 30

    When is manual JSON serialization using `fromJson` and `toJson` methods the most suitable approach?

    Show the answer

    Answer: b · When you need to quickly prototype a small application or process JSON with an unusual format.

    Option B is correct because the card states manual serialization is "perfect for small projects, quick prototypes, or when you need to handle oddly-structured JSON." Option D is incorrect as manual serialization is prone to runtime errors from misspelled keys, a problem code generation aims to solve.

    Read the full bite: Manual JSON Serialization with fromJson/toJson

  29. Question 29 of 30

    What is the primary function of the part 'my_file.g.dart'; directive in conjunction with json_serializable?

    Show the answer

    Answer: b · It links the main class file to the automatically generated serialization and deserialization functions.

    The 'part' directive is a Dart language feature that allows a file to include code from another file, making the generated serialization functions (like _YourClassFromJson) accessible to the main class. Option D is a tempting distractor because 'part' does relate to partial definitions, but it's for the generated code, not the json_annotation package itself.

    Read the full bite: json_serializable: Automating JSON in Dart

  30. Question 30 of 30

    Which feature of the W3C Design Tokens specification is most crucial for maintaining consistency across a design system when primitive values change?

    Show the answer

    Answer: b · The use of aliases, enabling semantic tokens to reference and resolve primitive values.

    Aliases are explicitly stated as the mechanism that allows semantic tokens to reference primitive values, ensuring a single change to a primitive propagates everywhere. While the standard JSON structure enables tool compatibility, aliases are key for internal system consistency during value updates.

    Read the full bite: W3C Design Tokens: A JSON Standard for Design Systems

Could you explain these out loud?

That is what an interview actually tests. Tezvyn gives you questions like these with what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon