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
function simdjson_key_value(string $json, string $key, bool $assoc = unknown, int $depth = unknown) {}
179
+
function simdjson_key_value(string $json, string $key, bool $associative = false, int $depth = 512) {}
152
180
153
181
/**
154
182
* An error thrown by simdjson when processing json.
@@ -160,12 +188,27 @@ function simdjson_key_value(string $json, string $key, bool $assoc = unknown, in
160
188
*/
161
189
class SimdJsonException extends RuntimeException {
162
190
}
191
+
192
+
/**
193
+
* Thrown for error conditions on fields such as $depth that are not expected to be
194
+
* from user-provided JSON, with similar behavior to php 8.0.
195
+
*
196
+
* NOTE: https://www.php.net/valueerror was added in php 8.0.
197
+
* In older php versions, this extends Error instead.
198
+
*
199
+
* When support for php 8.0 is dropped completely,
200
+
* a major release of simdjson will likely switch to a standard ValueError.
201
+
*/
202
+
class SimdJsonValueError extends ValueError {
203
+
}
163
204
```
164
205
165
206
## Edge cases
166
207
167
208
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.
168
209
210
+
Note that the simdjson PECL is using a fork of the simdjson C library to imitate php's handling of integers and floats in JSON.
211
+
169
212
1)**Until simdjson 2.1.0,**`simdjson_decode()` differed in how out of range 64-bit integers and floats are handled.
170
213
171
214
See https://github.com/simdjson/simdjson/blob/master/doc/basics.md#standard-compliance
* 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`
32
+
* Add SimdJsonValueError. In php 8.0+, it extends ValueError, and it extends Error in older php versions.
33
+
This provides an API similar to the JSON module, which started throwing ValueError for invalid depths in php 8.0.
34
+
* Throw SimdJsonValueError instead of emitting notices if $depth is too small or too large in all simdjson PHP functions.
35
+
simdjson_is_valid(), simdjson_key_count() and simdjson_key_exists() now have non-null return types.
36
+
* Throw a SimdJsonException in simdjson_key_exists on error conditions such as invalid json, to be consistent with other simdjson PHP functions.
37
+
* Add an optional boolean `$throw_if_uncountable = false` to simdjson_key_count.
38
+
When this is overridden to be true, simdjson_key_count will throw a SimdJsonException if the JSON pointer refers to a value that exists but is neither an array nor an object instead of returning 0.
39
+
* Rename the parameter $assoc to $associative in simdjson_decode and simdjson_key_value, to match naming practices used in json_decode()
* 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).
140
+
141
+
This allows simdjson_decode() to be used as a replacement for json_decode() in more use cases.
142
+
* Return the correct value in simdjson_key_count() for JSON pointers to arrays/objects exceeding size 0xFFFFFF.
143
+
Previously, this would be limited to returning at most 0xFFFFFF(16777215).
144
+
* Throw 'SimdJsonException extends RuntimeException' instead of RuntimeException.
145
+
* Set the error code from simdjson as SimdJsonException->getCode()
146
+
* Expose error_code constants from simdjson as `SIMDJSON_ERR_$ERRCODENAME`
0 commit comments