PHP code example of aayinde / json-office

1. Go to this page and download the library: Download aayinde/json-office 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/ */

    

aayinde / json-office example snippets



use Aayinde\JsonOffice\Writer\JsonArrayWriter;

$objJsonWriter = new JsonWriter();
$objJsonWriter->getInstanceJsonWriter()
    ->setInput($array)
    ->resultOutput();

$array = [
    'default' => [
        'config' => [
            'host' => 'localhost',
            'port' => 3306,
            'username' => "root",
            'password' => "root",
            'schema' => "test",
            'prefix' => "test",
            'socket' => null,
            'engine' => 'InnoDB',
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_general_ci',
            'timezone' => '+00:00',
            'ssl' => [
                'enabled' => false,
                'verify' => true,
                'key' => null,
                'cert' => null,
                'ca' => null,
                'capath' => null,
                'cipher' => null
            ],
            'failover' => [],
            'options' => [
                MYSQLI_OPT_CONNECT_TIMEOUT => 10,
                MYSQLI_OPT_INT_AND_FLOAT_NATIVE => true,
                MYSQLI_OPT_LOCAL_INFILE => 1
            ],
            'report' => MYSQLI_REPORT_ALL & ~ MYSQLI_REPORT_INDEX
        ],
        'logger_instance' => 'default'
    ]
];


use Aayinde\JsonOffice\Writer\JsonArrayWriter;

$objJsonWriter = new JsonWriter();
$objJsonWriter->getInstanceJsonWriter()
    ->setInput($array)
    ->saveToFile("test"));




$objJsonWriter = new JsonWriter();
$objJsonWriter->getInstanceJsonWriter()
    ->setInput($array)->useToPrettyPrint()
    ->resultOutput();


use Aayinde\JsonOffice\JsonReader;

$objJsonReader = new JsonReader();
$objJsonReader->getInstanceJsonFileReader()
    ->setReader("test.json")
    ->result();


use Aayinde\JsonOffice\JsonReader;
$objJsonReader = new JsonReader();
$objJsonReader->getInstanceJsonStringReader()
    ->setReader($readerInput)
    ->result();