liveBook · Manning

JSON object

As explained in Functional Programming in Scala, Second Edition

A JSON object is a JSON value containing comma-separated quoted-string keys paired with values and enclosed in curly braces.

A JSON object is a JSON value containing comma-separated key-value pairs enclosed in curly braces. Each key is a quoted string; each value may be another object, an array, or a literal such as a string, Boolean, null, or number. section 9.4.1

A company record

This object maps descriptive keys to values of different JSON types: strings for the company name and ticker, a Boolean for activity, numbers for price and shares, and an array for related companies.

A parsed object can be represented as JObject(get: Map[String, JSON]), turning the textual key-value sequence into a map whose values remain JSON values. Parsing then combines a quoted key with a colon and a value, accepts comma-separated pairs, and wraps the result in JObject.

How Functional Programming in Scala, Second Edition covers it

How deep it goes
Explains the grammar, data representation, and parser construction, while leaving primitive string and number parsers undefined.
Examples
Uses a company record containing strings, a Boolean, numbers, an array, and nested JSON-compatible values.
What it assumes
Assumes quoted strings, parser combinators, and JSON values while defining object grammar from its delimiters and separators.
What you can do after
Build it from scratch as a parser that produces JObject values from comma-separated JSON key-value pairs.
How it connects
Connects JSON objects with JSON values, JSON arrays, maps, syntax trees, and parser combinators.

Also explained in

Compare how 7 books explain JSON object →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Functional Programming in Scala, Second Edition. The section links point to the parts of the book it draws on.