JSON · Reading
JSON reading 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
Reading 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.
- 2
- examples
- 6
- documented methods
Json::read()withHeaderRow()streaming()rows()<?php
declare(strict_types=1);
/*
Summary:
Read a large top-level array incrementally with a stable output schema.
Implementation note:
Pin json_columns for heterogeneous records so every streamed row has deterministic field order.
*/
use Mnb\PHPExcel\Format\Json;
$rows = Json::read(__DIR__ . '/events.json', [
'stream_json_array' => true,
'json_columns' => ['id', 'type', 'created_at'],
'streaming_extra_keys' => 'error',
'max_json_record_bytes' => 2 * 1_024 * 1_024,
])->withHeaderRow(1)->streaming()->rows();Json::read()sheetNames()sheet()rows()<?php
declare(strict_types=1);
/*
Summary:
Discover named logical sheets and read one sheet as associative rows.
Implementation note:
Workbook-shaped JSON is materialized because sheet discovery depends on the complete document
structure.
*/
use Mnb\PHPExcel\Format\Json;
$session = Json::read(__DIR__ . '/workbook.json', [
'json_document_mode' => 'json',
]);
print_r($session->sheetNames());
$orders = $session->sheet('Orders')->withHeaderRow(1)->rows();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