With jq
jq --arg id "<character-uuid>" '
[.document.scenes[].body[]
| select(.type == "dialogue" and .character == $id)
| .text.en]' screenplay.json
Preserving scene context
jq --arg id "<character-uuid>" '
[.document.scenes[]
| { scene: .heading.setting, time: .heading.time,
lines: [.body[] | select(.type == "dialogue" and .character == $id) | .text.en] }
| select(.lines | length > 0)]' screenplay.json
Finding the character UUID first
jq '.characters[] | select(.name == "MARA") | .id' screenplay.json
In Node.js
import fs from 'node:fs/promises';
const doc = JSON.parse(await fs.readFile('screenplay.json', 'utf8'));
const mara = doc.characters.find((c) => c.name === 'MARA');
const lines = doc.document.scenes.flatMap((scene) =>
scene.body
.filter((el) => el.type === 'dialogue' && el.character === mara.id)
.map((el) => el.text.en),
);
console.log(lines.join('\n'));