PHP Classes

File: README.md

Recommend this page to a friend!
  Packages of Ramesh Narayan Jangid (Sharma)   Heavy JSON Decode   README.md   Download  
File: README.md
Role: Example script
Content type: text/markdown
Description: Example script
Class: Heavy JSON Decode
Parse and decode JSON data from a file or string
Author: By
Last change: Readme
Refactored
Date: 2 days ago
Size: 1,787 bytes
 

Contents

Class file image Download

JSON Decode

PHP JSON Decode large data with lesser resources

Examples

Validating JSON.

<?php

require_once __DIR__ . '/AutoloadJsonDecode.php';

use CustomJsonDecode\JsonDecoder;

// Creating json file handle
$fp = fopen('/usr/local/var/www/rnd/test.json', 'rb');

// Create JsonDecode Object.
JsonDecoder::init($fp);
$jsonDecodeObj = JsonDecoder::getObject();

// Validate JSON
$jsonDecodeObj->validate();

$jsonDecodeObj = null;

Accessing data of Array after indexing JSON.

<?php

require_once __DIR__ . '/AutoloadJsonDecode.php';

use CustomJsonDecode\JsonDecoder;

// Creating json file handle
$fp = fopen('/usr/local/var/www/rnd/test.json', 'rb');

// Create JsonDecode Object.
JsonDecoder::init($fp);
$jsonDecodeObj = JsonDecoder::getObject();

// Indexing JSON
$jsonDecodeObj->indexJson();

// Transverse across key 'data'
if (
    $jsonDecodeObj->isset('data') && $jsonDecodeObj->jsonType('data') === 'Array'
) {
    for ($i = 0, $iCount = $jsonDecodeObj->count('data'); $i < $iCount; $i++) {
        $key = "data:{$i}";

        // Row details without Sub arrays
        $row = $jsonDecodeObj->get($key);
        print_r($row);

        // Row with Sub arrays / Complete $key array recursively.
        $completeRow = $jsonDecodeObj->getCompleteArray($key);
        print_r($completeRow);
    }
}

$jsonDecodeObj = null;

? Contributing

Issues and feature requests are welcome.<br /> Feel free to share them on issues page

Author

? Ramesh N. Jangid (Sharma)

? License

Copyright © 2026 Ramesh N. Jangid (Sharma).<br /> This project is MIT licensed.