liveBook · Manning

JSON

As explained in DuckDB in Action

JSON is a text-based data interchange format representing structured values as objects, arrays, strings, numbers, booleans, and null.

JSON serves as a flexible interchange and storage format for structured or nested data. DuckDB can read it directly, destructure it, flatten it, transform it into relational tables, and store it using a JSON type. section 1.7.1

A practical workflow converts difficult source data into JSON, then into CSV when broader tool compatibility or smaller files matters. DuckDB can also load JSON directly when an intermediate CSV is unnecessary. section 10.1.1

Convert XML through JSON into compressed CSV

Extract selected comment fields with xidel, emit JSON, convert each record to CSV with jq, add a header, and compress the result: `7z e -so stackoverflow.com-Comments.7z | xidel -se '//row/[(@Id|@PostId|@Score|@Text|@CreationDate|@UserId)]' - | (echo "Id,PostId,Score,Text,CreationDate,UserId" && jq -r '. | @csv') | gzip -9 > Comments.csv.gz`. section 10.1.1

Listing 10.1 Converting the XML file via JSON to CSV
7z e -so stackoverflow.com-Comments.7z | \
xidel -se '//row/[(@Id|@PostId|@Score|@Text|@CreationDate|@UserId)]' - | \
(echo "Id,PostId,Score,Text,CreationDate,UserId" &&
jq -r '. | @csv') |
gzip -9 > Comments.csv.gz

Inspect the complete XML-to-JSON-to-CSV command pipeline. section 10.1.1

How DuckDB in Action covers it

How deep it goes
Explains direct loading, nesting, flattening, relational transformation, and command-line conversion, but does not detail JSON syntax.
Examples
Demonstrates Stack Overflow XML exports, xidel extraction, jq conversion, DuckDB loading, and compressed CSV output.
What it assumes
Assumes familiarity with structured files, command-line pipelines, and DuckDB-based data analysis.
What you can do after
Operate/configure JSON conversion pipelines and query or transform JSON data with DuckDB and command-line tools.
How it connects
Connects JSON with DuckDB, SQL, CSV, XML, Parquet, command-line processing, and Python data workflows.

Also explained in

Compare how 35 books explain JSON →

Related concepts

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