JSON Module
Read and write JSON arrays, workbook-shaped objects, JSON Lines, and NDJSON with streaming support.
Updated
Json::read()Json::write()JsonReader::readWorkbook()JsonWriter::payloadToString()What you will learn
- Choose standard JSON, top-level array streaming, or NDJSON.
- Normalize records into a spreadsheet-style row session.
- Write rows or complete workbook payloads.
Install the JSON package#
composer require mnb/mnb-phpexcel:^2.0Supported document shapes#
| Shape | Behavior |
|---|---|
| Top-level row array | Streams items one at a time by default. |
| NDJSON / JSON Lines | Reads one JSON value per non-empty line. |
| Workbook-shaped object | Materializes document structure so named sheets can be selected. |
| Single object or nested data | Normalized according to json_mode and column options. |
Read and write rows#
use Mnb\PHPExcel\Format\Json;
$rows = Json::read('customers.json')
->withHeaderRow(1)
->rows();use Mnb\PHPExcel\Format\Json;
Json::write($customers, 'customers.json', [
'pretty' => true,
'preserve_zero_fraction' => true,
]);Was this guide useful?Use GitHub issues for corrections, missing examples, or unclear behavior.
Open an issue