PHP code example of falbar / helper-json

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

    

falbar / helper-json example snippets


$sData = '{"key1":"value1","key2":"value2"}';

$bFlag = JsonHelper::isJson($sData);

$sData = '{"key1":"value1","key2":"value2"}';

$arData = JsonHelper::make()->data($sData)->decode();

$sPath = 'data.json'; // in file string {"key1":"value1","key2":"value2"}

$arData = JsonHelper::make()->data($sPath)->decode();

$arData = [
    'key1' => 'value1',
    'key2' => 'value2',
];

$sData = JsonHelper::make()->data($arData)->encode();
text
array(2) {
  ["key1"]=> string(6) "value1"
  ["key2"]=> string(6) "value2"
}
text
array(2) {
  ["key1"]=> string(6) "value1"
  ["key2"]=> string(6) "value2"
}