PHP Classes

How to Implement PHP json_decode Function in Pure PHP to Be Able to Decode Large JSON Data Heavy JSON Decode: Parse and decode JSON data from a file or string

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-11-02 (Yesterday) RSS 2.0 feedNot enough user ratingsTotal: 19 This week: 3All time: 11,325 This week: 12Up
Version License PHP version Categories
heavyjsondecode 1.0MIT/X Consortium ...5PHP 5, Data types, Parsers
Description 

Author

This class can parse and decode JSON data from a file or string.

It can take a file name or a string as a parameter to specify the data source to read the JSON data.

The class can read and parse the JSON data and returns an array of JSON elements.

Picture of Ramesh Narayan Jangid
  Performance   Level  
Name: Ramesh Narayan Jangid <contact>
Classes: 10 packages by
Country: India India
Innovation award
Innovation award
Nominee: 5x

Winner: 3x

Example

JSON Decode

PHP JSON Decode large data with lesser resources

Examples

Validating JSON.

<?php
require "JsonDecode.php";

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

// Create JsonEncode Object.
$JsonDecode = new JsonDecode($fp);
$JsonDecode->init();

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

$jsonDecode = null;

Accessing data of Array after indexing JSON.

<?php
require "JsonDecode.php";

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

// Create JsonEncode Object.
$JsonDecode = new JsonDecode($fp);
$JsonDecode->init();

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

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

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

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

$jsonDecode = null;


  Files folder image Files (3)  
File Role Description
Plain text file JsonDecode.php Class Heavy Json Decode
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Example Example script

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:19
This week:3
All time:11,325
This week:12Up