src/MASNathan/Curl/StringParser.php
static public function toJson($str)
    {
        $data = \json_decode($str, true);

        switch (json_last_error()) {
            case JSON_ERROR_NONE:
            	return $data;
	        case JSON_ERROR_DEPTH:
	            return array('error' => 'Maximum stack depth exceeded');
	        case JSON_ERROR_STATE_MISMATCH:
	            return array('error' => 'Underflow or the modes mismatch');
	        case JSON_ERROR_CTRL_CHAR:
	            return array('error' => 'Unexpected control character found');
	        case JSON_ERROR_SYNTAX:
	            return array('error' => 'Syntax error, malformed JSON');
	        case JSON_ERROR_UTF8:
	            return array('error' => 'Malformed UTF-8 characters, possibly incorrectly encoded');
	        default:
	            return array('error' => 'Unknown error on JSON file');
        }
    }
static public function toJson($str)
    {
        $data = \json_decode($str, true);

        switch (json_last_error()) {
            case JSON_ERROR_NONE:
            	return $data;
	        case JSON_ERROR_DEPTH:
	            return array('error' => 'Maximum stack depth exceeded');
	        case JSON_ERROR_STATE_MISMATCH:
	            return array('error' => 'Underflow or the modes mismatch');
	        case JSON_ERROR_CTRL_CHAR:
	            return array('error' => 'Unexpected control character found');
	        case JSON_ERROR_SYNTAX:
	            return array('error' => 'Syntax error, malformed JSON');
	        case JSON_ERROR_UTF8:
	            return array('error' => 'Malformed UTF-8 characters, possibly incorrectly encoded');
	        default:
	            return array('error' => 'Unknown error on JSON file');
        }
    }
static public function toJson ( $ str ) { $ data = \ json_decode ( $ str , true ) ; switch ( json_last_error ( ) ) { case JSON_ERROR_NONE : return $ data ; case JSON_ERROR_DEPTH : return array ( 'error' => 'Maximum stack depth exceeded' ) ; case JSON_ERROR_STATE_MISMATCH : return array ( 'error' => 'Underflow or the modes mismatch' ) ; case JSON_ERROR_CTRL_CHAR : return array ( 'error' => 'Unexpected control character found' ) ; case JSON_ERROR_SYNTAX : return array ( 'error' => 'Syntax error, malformed JSON' ) ; case JSON_ERROR_UTF8 : return array ( 'error' => 'Malformed UTF-8 characters, possibly incorrectly encoded' ) ; default : return array ( 'error' => 'Unknown error on JSON file' ) ; } }
Parses a json string into an array
@param string $str
@return array
Parses a json string into an array