Essence\Utility\Json::parse PHP Method

parse() public static method

Parses a JSON document and returns an array of data.
public static parse ( string $json ) : array
$json string JSON document.
return array Data.
    public static function parse($json)
    {
        $data = json_decode($json, true);
        if ($data === null) {
            throw new Exception('Error parsing JSON response: ' . self::$_errors[json_last_error()] . '.');
        }
        return $data;
    }

Usage Example

Example #1
0
 /**
  *	Loads configuration from an array or a file.
  *
  *	@param array|string $config A configuration array, or a JSON
  *		configuration file.
  */
 public function load($config)
 {
     if (is_string($config) && file_exists($config)) {
         $json = file_get_contents($config);
         $config = Json::parse($json);
     }
     $this->configure($config);
 }
All Usage Examples Of Essence\Utility\Json::parse
Json