MNB PHPExcelDeveloper Guide

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.

Packagemnb/mnb-phpexcel-json:^2.0Reference2 examples · 6 methods
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
Example 01

Stream a top-level JSON array

Open related guide
Json::read()withHeaderRow()streaming()rows()
stream-a-top-level-json-array.php
<?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();