simdjson_decode Decodes a JSON string &reftitle.description; mixedsimdjson_decode stringjson boolassociative&false; intdepth512 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. &reftitle.parameters; json The json string being 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. associative When &true;, JSON objects will be returned as associative &array;s; when &false;, JSON objects will be returned as &object;s. 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. &reftitle.returnvalues; Returns the value encoded in json in appropriate PHP type. Values true, false and null are returned as &true;, &false; and &null; respectively. &reftitle.errors; If json is invalid, 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. &reftitle.examples; <function>simdjson_decode</function> examples ]]> &example.outputs; int(1) ["b"]=> int(2) ["c"]=> int(3) } array(3) { ["a"]=> int(1) ["b"]=> int(2) ["c"]=> int(3) } ]]> 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. {'foo-bar'}; // 12345 ?> ]]> common mistakes using <function>simdjson_decode</function> ]]> <parameter>depth</parameter> errors array -> array -> string) $json = json_encode( [ 1 => [ 'English' => [ 'One', 'January' ], 'French' => [ 'Une', 'Janvier' ] ] ] ); // Show the errors for different depths. var_dump(simdjson_decode($json, true, 4)); try { var_dump(simdjson_decode($json, true, 3)); } catch (SimdJsonException $e) { echo "Caught: ", $e->getMessage(), "\n"; } ?> ]]> &example.outputs; 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) ]]> <function>simdjson_decode</function> of large integers ]]> &example.outputs; float(1.2345678901235E+19) } ]]> &reftitle.notes; The JSON spec is not JavaScript, but a subset of JavaScript. In the event of a failure to decode, a SimdJsonException is thrown and SimdJsonException::getCode and SimdJsonException::getMessage can be used to determine the exact nature of the error. &reftitle.seealso; json_encode json_decode