JSON · Structured output
JSON structured output examples.
Package-local, copy-ready examples organized like the classes and methods reference. Open one example at a time, search by method, and jump from the right-side index.
JSON individual library
Structured output examples with copy-ready, production-minded PHP.
Every snippet uses mnb/mnb-phpexcel-json or its declared Core dependency. Each copied snippet includes strict typing, a concise summary, implementation guidance, readable limits, and a safe fixture check.
- 1
- examples
- 2
- documented methods
toStructuredJson()saveStructuredJson()<?php
declare(strict_types=1);
/*
Summary:
Return workbook-aware rows, counts, warnings, and source metadata as an API response.
Implementation note:
Structured output preserves the reader summary and warnings instead of returning only a flat
list of rows.
*/
use Mnb\PHPExcel\Format\Json;
$json = Json::read(__DIR__ . '/report.json')
->withHeaderRow(1)
->toStructuredJson(
readOptions: ['preserve_original_row_numbers' => true],
jsonOptions: ['pretty' => true]
);
header('Content-Type: application/json; charset=UTF-8');
echo $json;No matching example found.Try a method name, task, or result.
Was this guide useful?Use GitHub issues for corrections, missing examples, or unclear behavior.
Open an issue