'School Policy', 'sections' => [ [ 'subsections' => [ [ 'body' => $html, ], ], ], ], ]; $outDir = $root . '/public/policy'; if (!is_dir($outDir)) { mkdir($outDir, 0777, true); } $json = json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); if ($json === false) { fwrite(STDERR, "json_encode failed\n"); exit(1); } file_put_contents($outDir . '/school-policy-content.json', $json); echo "Wrote public/policy/school-policy-content.json\n";