PHP code example of victorap93 / readjson

1. Go to this page and download the library: Download victorap93/readjson library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

victorap93 / readjson example snippets


use \victorap93\ReadJson;

$json_path = "./stores.json";

// Get all json content.
$ReadJson = new ReadJson($json_path);
$json_object_value1 = $ReadJson->getJsonObject();

// Accessing the obtained object.
$json_object_value2 = $json_object_value1->stores[0]->products;

// Get a specified json content position in instance of class.
$ReadJson = new ReadJson($json_path, ['stores', 0, 'products']);
$json_object_value3 = $ReadJson->getJsonObject();

// Get a specified json content position in method call.
$ReadJson = new ReadJson($json_path, ['stores', 0]);
$json_object_value4 = $ReadJson->getJsonObject(['products']);

// Get a specified json content position with object.
$json_object_value5 = $ReadJson->accessRecursiveKeys($json_object_value4, [0, 'name']);