MNB PHPExcelDeveloper Guide

JSON · Basic

JSON basic 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.0Reference1 examples · 1 methods
JSON individual library

Basic 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
1
documented methods
Example 01

Write formatted JSON rows

Open related guide
Json::write()
write-formatted-json-rows.php
<?php

declare(strict_types=1);

/*
Summary:
    Serialize normalized rows with readable formatting and stable numeric output.

Implementation note:
    Use compact output for network payloads and pretty output for human-reviewed files or fixtures.
*/

use Mnb\PHPExcel\Format\Json;

Json::write($rows, __DIR__ . '/products.json', [
    'pretty' => true,
    'preserve_zero_fraction' => true,
    'trailing_newline' => true,
]);