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-07-05 (1 month ago) RSS 2.0 feedNot yet rated by the usersTotal: 12 All time: 11,379 This week: 63Up
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: 9 packages by
Country: India India
Innovation award
Innovation award
Nominee: 4x

Winner: 2x

Example

JSON Decode

PHP JSON Decode large data with lesser resources

Examples

Validating JSON.

<?php
require "JsonDecode.php";

// Create JsonEncode Object.
$JsonDecode = new JsonDecode('/usr/local/var/www/rnd/test.json');

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

$jsonDecode = null;

Generating hierarchy output.

<?php
require "JsonDecode.php";

// Create JsonEncode Object.
$JsonDecode = new JsonDecode('/usr/local/var/www/rnd/test.json');

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

// Get hierarchy output 
foreach($JsonDecode->process() as $keys => $arr) {
    var_dump($keys);
    var_dump($arr);
}

$jsonDecode = null;

Indexing JSON.

<?php
require "JsonDecode.php";

// Create JsonEncode Object.
$JsonDecode = new JsonDecode('/usr/local/var/www/rnd/test.json');

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

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

$jsonDecode = null;

Accessing data via keys pattern.

<?php
require "JsonDecode.php";

// Create JsonEncode Object.
$JsonDecode = new JsonDecode('/usr/local/var/www/rnd/test.json');

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

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

// Load specific Keys seperated by colon
$JsonDecode->load('data:0:data1');

// Get hierarchy output based on loaded keys
foreach($JsonDecode->process() as $keys => $arr) {
    var_dump($keys);
    var_dump($arr);
}

$jsonDecode = null;

Accessing data of Array after indexing JSON.

<?php
require "JsonDecode.php";

// Create JsonEncode Object.
$JsonDecode = new JsonDecode('/usr/local/var/www/rnd/test.json');

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

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

// Transverse across object key 'data'
for ($i=0, $i_count = $JsonDecode->getCount('data'); $i < $i_count; $i++) {
     print_r($JsonDecode->get('data:'.$i));
}

$jsonDecode = null;


  Files folder image Files (4)  
File Role Description
Accessible without login Plain text file composer.json Data Auxiliary data
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:12
This week:0
All time:11,379
This week:63Up