liveBook · Manning

JSONL

As explained in DuckDB in Action

JSON Lines is a text format that stores one complete JSON value, typically an object, per line.

JSONL stores one complete JSON value, typically one object, per line. It supports practical data exploration because DuckDB can read multiple matching files, infer fields, and convert JSON values into queryable vectors. section 5.3

A useful JSONL workflow includes:

  • Read a file collection with a wildcard such as xg/shots_*.json. section 5.3
  • Unnest nested arrays into rows, combining home and away events with UNION ALL. section 5.3
  • Inspect inferred schemas and cast fields such as X, Y, and xG to consistent numeric types. section 5.3

Flattening JSONL match data

FROM 'xg/shots_*.json' SELECT unnest(h) AS row UNION ALL FROM 'xg/shots_*.json' SELECT unnest(a) AS row LIMIT 3; Create a view from the combined rows, select row.* to flatten each STRUCT, then aggregate expected goals and goals by team. section 5.3

.mode line
DESCRIBE FROM 'xg/shots_*.json';

Inspect the inferred schema directly in DuckDB CLI before flattening or repairing JSONL data. section 5.3

How DuckDB in Action covers it

How deep it goes
Explains file discovery, schema inference, array unnesting, recursive expansion, and whole-STRUCT casting.
Examples
Demonstrates Premier League shot files, wildcard reads, home-and-away arrays, inferred schemas, and expected-goals aggregation.
What it assumes
Assumes JSON files and DuckDB CLI familiarity while demonstrating the needed unnesting and schema-repair operations.
What you can do after
Apply it via DuckDB SQL to inspect, flatten, type-correct, and aggregate multiple JSONL files.
How it connects
Connects JSONL with JSON, DuckDB, SQL, nested data, schema inference, and data flattening.

Also explained in

Compare how 3 books explain JSONL →

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.