Decode JSON string.

@param $json_str String to parse.
@param $filename If set the exception message will contain $filename.
973856
static function parse_json_string($json_str, $filename = null)
	{
		$data = json_decode($json_str, TRUE, 512, JSON_BIGINT_AS_STRING);
		$error = json_last_error();
		if ($error !== JSON_ERROR_NONE) {
			throw new JsonException($filename !== null ? json_last_error_msg().' ('.$filename.')' : json_last_error_msg(), $error);
		}
		return $data;
	}
466936
function decode($json, $assoc = true, $depth = 512, $options = 0) {
        if (array_contains(['', null], $json)) {
            return null;
        }

        $data = @json_decode($json, $assoc, $depth, $options);
        
        if ($data === null && json_last_error() !== JSON_ERROR_NONE) {
            throw new JsonDecodeException(json_last_error_msg(), $json);
        }

        return $data;
    }
574295
public function deserialize($jsonString, $className)
    {
        if (!$this->isValidClassName($className)) {
            throw new \Exception($className.' is not defined in OpenApi PHP Annotations');
        }
        return $this->doDeserialize(json_decode($jsonString), $className);
    }
1272112
public static function decode(string $json)
    {
        $value = json_decode($json, true, 512, JSON_BIGINT_AS_STRING);

        if ($error = json_last_error()) {
            throw new JsonException(json_last_error_msg(), $error);
        }

        return $value;
    }
656865
public function readFile(string $file_name)
    {
        $contents = @file_get_contents($file_name);
        if ($contents === false)
            throw new IOException("Failed to read file contents");

        $contents = Encoding::removeBOM($contents);
        return $this->readString(file_get_contents($file_name));
    }
1017383
protected function jsonDecode($json)
    {
        // From firebase/php-jwt
        if (!(defined('JSON_C_VERSION') && PHP_INT_SIZE > 4)) {
            /**
             * In PHP >=5.4.0, json_decode() accepts an options parameter, that allows you
             * to specify that large ints (like Steam Transaction IDs) should be treated as
             * strings, rather than the PHP default behaviour of converting them to floats.
             */
            $obj = json_decode($json, false, 512, JSON_BIGINT_AS_STRING);
        } else {
            // @codeCoverageIgnoreStart
            /**
             * Not all servers will support that, however, so for older versions we must
             * manually detect large ints in the JSON string and quote them (thus converting
             * them to strings) before decoding, hence the preg_replace() call.
             * Currently not sure how to test this so I ignored it for now.
             */
            $maxIntLength = strlen((string) PHP_INT_MAX) - 1;
            $jsonWithoutBigints = preg_replace('/:\s*(-?\d{'.$maxIntLength.',})/', ': "$1"', $json);
            $obj = json_decode($jsonWithoutBigints);
            // @codeCoverageIgnoreEnd
        }

        return $obj;
    }
1159823
private function decodeJson( $json ) {
		$error = $errorMsg = null;
		$return = json_decode( $json );
		if ( $return === null && trim( $json ) !== 'null' ) {
			$error = json_last_error();
			$errorMsg = json_last_error_msg();
		} elseif ( !$return || !is_object( $return ) ) {
			$error = 128;
			$errorMsg = 'Response must be an object';
		}

		if ( $error ) {
			$this->logger->error(
				'Failed to decode server response as JSON: {message}',
				[
					'response' => $json,
					'code' => json_last_error(),
					'message' => json_last_error_msg(),
				]
			);
			throw new Exception( 'Decoding server response failed: ' . json_last_error_msg()
				. " (Raw response: $json)" );
		}
		return $return;
	}
1107422
public static function getJson(string $filename, array $defaultValue = []): array
    {
        if (!Str::endsWith($filename, '.json')) {
            $filename .= '.json';
        }
        $data = self::get($filename);
        if ($data === '') {
            return $defaultValue;
        }
        $data = json_decode($data, true);
        if ($data === null || $data === false) {
            $data = [];
        }
        return $data;
    }
1078891
def load_json_object(file_name, default=None):
    
    if not os.path.isfile(file_name):
        return default

    # use utf-8-sig in case the file has a Byte Order Mark
    with codecs.open(file_name, 'r', 'utf-8-sig') as in_file:
        # read the text from the file
        content = in_file.read()

    # convert Windows line endings to Linux line endings
    content = content.replace('\r\n', '\n')

    # return a deserialized object
    return json.loads(content)
785631
private function parseJson($jsonString)
    {
        $jsonData = json_decode($jsonString, true);

        if ($jsonData === null) {
            $this->emit('error', [json_last_error_msg()]);
            return;
        }

        $this->setContent($jsonString);
        $this->setData($jsonData);
        $this->emit('end');
    }
795117
public function
	Read(String $Filename=NULL) {

		if($Filename === NULL) $Filename = $this->Filename;
		else $this->Filename = $Filename;

		if(!$Filename)
		throw new Exception('No filename specified.');

		$Basename = basename($Filename);
		$Ext = NULL;

		if(strpos($Basename,'.') !== FALSE)
		$Ext = strtolower(explode('.',$Basename,2)[1]);

		////////
		////////

		if(!file_exists($Filename))
		throw new Exception("File {$Basename} not found.");

		if(!is_readable($Filename))
		throw new Exception("File {$Basename} is not readable.");

		////////
		////////

		if($Ext === 'json' || $this->Format === static::FormatJSON)
		$this->Data = json_decode(file_get_contents($Filename));

		elseif($Ext === 'phson' || $this->Format === static::FormatPHP)
		$this->Data = unserialize(file_get_contents($Filename));

		////////
		////////

		if(is_object($this->Data))
		$this->Data = (array)$this->Data;

		return $this;
	}
1074703
protected function _json_decode($data, $need_array = false)
  {
    if (!(defined('JSON_C_VERSION') && PHP_INT_SIZE > 4)) {
      return json_decode($data, $need_array, 512, JSON_BIGINT_AS_STRING);
    }
    return json_decode($data, $need_array);
  }
500161
def from_json(cls, filename):
        
        with open(filename) as fp:
            raw = json.load(fp)

        return cls(raw['stimuli'], raw['inhibitors'], raw['readouts'])
174807
public static function read($fileName)
    {
        $data = parent::read($fileName);

        $json = json_decode($data, true);

        if (json_last_error()) {
            throw new \RuntimeException(json_last_error_msg());
        }

        return $json;
    }
597064
public static function parseErrors($json_string)
    {
        $error_obj = json_decode($json_string);
        $errors = [];
        if (!empty($error_obj->errors)) {
            foreach ($error_obj->errors as $error) {
                $errors[] = new self($error->code, $error->path, $error->description);
            }
        } elseif (!empty($error_obj->error)) {
            $errors[] = new self('', '', $error_obj->error);
        }

        return $errors;
    }
527119
def get_json(filename):
    
    check_if_this_file_exist(filename)

    #Process this function
    filename = os.path.abspath(filename)
    s = command_line(['exiftool', '-G', '-j', '-sort', filename])
    if s:
        #convert bytes to string
        s = s.decode('utf-8').rstrip('\r\n')
        return json.loads(s)
    else:
        return s
775919
static public JSONArray parse(String str) throws IOException {
        StringReader strReader = new StringReader(str);
        return parse(strReader);
    }