PHP code example of pnz / json-exception

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

    

pnz / json-exception example snippets


 $data = json_decode($jsonString, ...);
 if (ERROR_NONE !== json_last_error()) {
     // handle the error: thown a custom exception, or return
     // $error = json_last_error_msg();
     // $errorCode = json_last_error();
 }

try {
    $data = Json::decode($jsonString, ...);
} catch(\JsonException $e) {
   // Handle the exception
}