You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2.1.0-dev: Add SimdJsonException, update C simdjson
This uses the `simdjson_php` branch of
https://github.com/TysonAndre/simdjson
- This makes the result of numeric edge cases match phps for values
that would overflow to infinity (with the simdjson dom parser)
(e.g. 1e999) discovered in the compatibility tests
- Merges in bug fixes from simdjson 3.0.0
e.g. for https://en.wikipedia.org/wiki/Signed_zero
Import various tests from php-src ext/json to test compatibility
Mark other dependencies on json to run tests
Mark a test as php 7.1+ only
Add more tests of parsing large floating point numbers
Switch from RuntimeException to SimdJsonException
1. Change to SimdJsonException extends RuntimeException.
The name was chosen to be similar to https://www.php.net/jsonexception
JsonException.
2. Set the value of $e->getCode()
3. Add global constants `SIMDJSON_ERR_*`
4. Throw SimdJsonException instead for invalid properties
Disable development checks in debug builds and disable exception support
to force manual error handling of all possible error conditions
(this library is called from php, which is written in C)
Fix Windows build error, make bindings consistently ZEND_API
* @throws RuntimeException for invalid JSON (or document over 4GB, or out of range integer/float)
114
114
*/
115
115
function simdjson_decode(string $json, bool $assoc = false, int $depth = 512) {}
116
116
117
117
/**
118
118
* Returns true if json is valid.
119
119
*
120
-
* @returns ?bool (null if depth is invalid)
120
+
* @return ?bool (null if depth is invalid)
121
121
*/
122
122
function simdjson_is_valid(string $json, int $depth = 512) : ?bool {}
123
123
124
124
/**
125
125
* Parses $json and returns the number of keys in $json matching the JSON pointer $key
126
126
*
127
-
* @returns ?bool (null if depth is invalid)
127
+
* @return ?int (null if depth is invalid)
128
128
*/
129
129
function simdjson_key_count(string $json, string $key, int $depth = 512) : ?int {}
130
130
131
131
/**
132
132
* Returns true if the JSON pointer $key could be found.
133
133
*
134
-
* @returns ?bool (null if depth is invalid, false if json is invalid or key is not found)
134
+
* @return ?bool (null if depth is invalid, false if json is invalid or key is not found)
135
135
*/
136
136
function simdjson_key_exists(string $json, string $key, int $depth = 512) : ?bool {}
137
137
138
138
/**
139
139
* Returns the value at $key
140
140
*
141
-
* @returns array|stdClass|string|float|int|bool|null the value at $key
141
+
* @return array|stdClass|string|float|int|bool|null the value at $key
142
142
* @throws RuntimeException for invalid JSON (or document over 4GB, or out of range integer/float)
143
143
*/
144
144
function simdjson_key_value(string $json, string $key, bool $assoc = unknown, int $depth = unknown) {}
@@ -148,7 +148,7 @@ function simdjson_key_value(string $json, string $key, bool $assoc = unknown, in
148
148
149
149
There are some differences from `json_decode()` due to the implementation of the underlying simdjson library. This will throw a RuntimeException if simdjson rejects the JSON.
150
150
151
-
1)`simdjson_decode()` how out of range 64-bit integers and floats are handled.
151
+
1)**Until simdjson 2.1.0,**`simdjson_decode()`differed in how out of range 64-bit integers and floats are handled.
152
152
153
153
See https://github.com/simdjson/simdjson/blob/master/doc/basics.md#standard-compliance
* Reuse PHP's 1-byte and 0-byte interned strings in simdjson_decode, reducing memory usage for those strings. (e.g. for the key/value in '{"x":""}')
33
-
* Return correct count in simdjson_key_count. Properly return counts larger than 0xFFFFFF instead of returning 0xFFFFFF.
32
+
* Allow out of range 64-bit values in JSON integer syntax and allow floating point values outside of the max/min finite floating point values (i.e. parsing to +/- infinity).
33
+
34
+
This allows simdjson_decode() to be used as a replacement for json_decode() in more use cases.
35
+
* Return the correct value in simdjson_key_count() for JSON pointers to arrays/objects exceeding size 0xFFFFFF.
36
+
Previously, this would be limited to returning at most 0xFFFFFF(16777215).
37
+
* Throw 'SimdJsonException extends RuntimeException' instead of RuntimeException.
38
+
* Set the error code from simdjson as SimdJsonException->getCode()
39
+
* Expose error_code constants from simdjson as `SIMDJSON_ERR_$ERRCODENAME`
0 commit comments