Lexical analysis converts an input character sequence into an ordered list of tokens. In JSON deserialization, it is the first stage: the lexer prepares input for the parser, which recognizes higher-level structures before deserialization creates Kotlin objects. section 12.2.4
JSON lexical analysis produces two token categories:
- Character tokens represent syntax characters such as commas, colons, braces, and brackets. section 12.2.4
- Value tokens represent string, number, Boolean, and null constants; examples include "Catch-22" and 42. section 12.2.4
Figure 12.8 The process of parsing JSON: first, the lexer takes the input text and divides it into tokens. Then, the parser processes the different semantic elements. Finally, the deserializer turns them into the final Kotlin objects.
Follow the parsing pipeline from source text to tokens, semantic JSON elements, and final Kotlin objects. section 12.2.4
