simdjson_decodeDecodes a JSON string 説明
mixed simdjson_decode(string
$json , bool $associative = false , int $depth = 512)Takes a JSON encoded string and converts it into a PHP value. This uses a faster Simultaneous Instruction, Multiple Data implementation than json_decode when it is supported by the computer architecture. パラメータ
戻り値
Returns the value encoded in エラー / 例外
If
If 例
例1 simdjson_decode examples
<?php 上の例の出力は以下となります。 object(stdClass)#1 (3) { ["a"]=> int(1) ["b"]=> int(2) ["c"]=> int(3) } array(3) { ["a"]=> int(1) ["b"]=> int(2) ["c"]=> int(3) } 例2 Accessing invalid object properties Accessing elements within an object that contain characters not permitted under PHP's naming convention (e.g. the hyphen) can be accomplished by encapsulating the element name within braces and the apostrophe.
<?php 例3 common mistakes using simdjson_decode
<?php 例4
<?php 上の例の出力は以下となります。 array(1) { [1]=> array(2) { ["English"]=> array(2) { [0]=> string(3) "One" [1]=> string(7) "January" } ["French"]=> array(2) { [0]=> string(3) "Une" [1]=> string(7) "Janvier" } } } Caught: The JSON document was too deep (too many nested objects and arrays) 例5 simdjson_decode of large integers
<?php 上の例の出力は以下となります。 object(stdClass)#1 (1) { ["number"]=> float(1.2345678901235E+19) } 注意
参考
|