Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ PHP NEWS
- JSON:
. Enriched JSON last error / exception message with error location.
(Juan Morales)
. Added JSON_DUPLICATE_KEY_MERGE and JSON_DUPLICATE_KEY_ARRAY flags to
json_decode() to control handling of duplicate object keys. (PurHur)

- Fibers:
. Fixed bug GH-20483 (ASAN stack overflow with fiber.stack_size INI small
Expand Down
2 changes: 2 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ PHP 8.6 UPGRADE NOTES
- JSON:
. Added extra info about error location to the JSON error messages returned
from json_last_error_msg() and JsonException message.
. Added JSON_DUPLICATE_KEY_MERGE and JSON_DUPLICATE_KEY_ARRAY flags to
json_decode() for duplicate object key handling.

- OpenSSL:
. Added TLS session resumption support for streams with new stream context
Expand Down
5 changes: 5 additions & 0 deletions ext/json/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ PHP_FUNCTION(json_decode)
RETURN_THROWS();
}

if ((options & PHP_JSON_DUPLICATE_KEY_MERGE) && (options & PHP_JSON_DUPLICATE_KEY_ARRAY)) {
zend_argument_value_error(4, "cannot combine JSON_DUPLICATE_KEY_MERGE and JSON_DUPLICATE_KEY_ARRAY");
RETURN_THROWS();
}

/* For BC reasons, the bool $assoc overrides the long $options bit for PHP_JSON_OBJECT_AS_ARRAY */
if (!assoc_null) {
if (assoc) {
Expand Down
11 changes: 11 additions & 0 deletions ext/json/json.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@
*/
const JSON_THROW_ON_ERROR = UNKNOWN;

/**
* @var int
* @cvalue PHP_JSON_DUPLICATE_KEY_MERGE
*/
const JSON_DUPLICATE_KEY_MERGE = UNKNOWN;
/**
* @var int
* @cvalue PHP_JSON_DUPLICATE_KEY_ARRAY
*/
const JSON_DUPLICATE_KEY_ARRAY = UNKNOWN;

/**
* @var int
* @cvalue PHP_JSON_ERROR_NONE
Expand Down
4 changes: 3 additions & 1 deletion ext/json/json_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading