PHP code example of mihasicehcek / json_parser

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

    

mihasicehcek / json_parser example snippets


try{
  $json = '{"integer":1';
  $result = \JsonParser\JsonParser::jsonDecode('{"integer":1');
}catch(\JsonParser\Exception $ex){
  print_r("Message: ".$ex->getMessage().", code: ".$ex->getCode()); //Message: Syntax error, code: 4
}

try{
  $a = new stdClass();
  $b = new stdClass();
  $a->b = $b;
  $b->a = $a;
  $result = \JsonParser\JsonParser::jsonEncode($a);
}catch(\JsonParser\Exception $ex){
  print_r("Message: ".$ex->getMessage().", code: ".$ex->getCode()); //Message: The object or array passed to json_encode