哈希空间 Ctrl + F 进行搜索
首页 php手册中文版 CSS中文手册 哈希文档 Markdown在线工具

PHP simdjson 组件

simdjson_key_value

(PECL simdjson >= 2.0.0)

simdjson_key_valueDecodes the value of a JSON string located at the requested JSON pointer.

说明

simdjson_key_value(
    string $json,
    string $key,
    bool $associative = false,
    int $depth = 512
): mixed

Decodes and returns the value found at the requested JSON pointer.

参数

json

The json string being queried and decoded.

This function only works with UTF-8 encoded strings.

This function parses valid inputs which json_decode() can decode, provided that they are less than 4 GiB long.

key

The JSON pointer string.

associative

When true, JSON objects will be returned as associative arrays; when false, JSON objects will be returned as objects.

depth

Maximum nesting depth of the structure being decoded. The value must be greater than 0, and less than or equal to 2147483647. Callers should use reasonably small values, because larger depths require more buffer space and will increase the recursion depth, unlike the current json_decode() implementation.

返回值

Returns the part of the value encoded in json that key refers to in appropriate PHP type. Values true, false and null are returned as true, false and null respectively.

错误/异常

If json or key is invalid, or key could not be found within json, a SimdJsonException is thrown as of PECL simdjson 2.1.0, while previously, a RuntimeException was thrown.

If depth is outside the allowed range, a SimdJsonValueError is thrown as of PECL simdjson 3.0.0, while previously, an error of level E_WARNING was raised.

参见

打开 哈希空间 微信小程序中查看更佳