liveBook · Manning

Parsing

As explained in Kotlin in Action, 2E

Parsing is the analysis of input according to structural or syntactic rules to identify its components and produce a structured, usable representation.

Parsing converts a list of tokens into a structured representation. In JSON deserialization, it identifies objects, arrays, and key-value pairs after lexical analysis, then communicates discoveries to the deserializer. section 12.2.4

A JSON deserialization pipeline separates responsibilities:

  • The lexer divides characters into character tokens and value tokens such as strings, numbers, Booleans, and null. section 12.2.4
  • The parser interprets tokens as semantic elements and calls callbacks for simple properties, nested objects, and arrays. section 12.2.4
  • The deserializer uses those parsed elements and reflection to construct Kotlin objects. section 12.2.4

Nested JSON

Parsing the JSON containing a book title and nested author identifies the title value, the author object, and the author's name before deserialization produces a Book instance. section 12.2.4

How Kotlin in Action, 2E covers it

How deep it goes
Explains token categories, semantic elements, and callback behavior while leaving final object creation to deserialization.
Examples
Uses nested book-and-author JSON and a JsonObject callback interface to illustrate parsed values, objects, and arrays.
What it assumes
Assumes JSON input and Kotlin object deserialization, while defining lexical analysis, tokens, parsers, and semantic elements.
What you can do after
Understand how JSON text progresses from characters to tokens, semantic structures, and final Kotlin objects.
How it connects
Connects parsing with lexical analysis, JSON, reflection, deserialization, objects, arrays, and key-value pairs.

Also explained in

Compare how 13 books explain parsing →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kotlin in Action, 2E. The section links point to the parts of the book it draws on.