[wp-trac] [WordPress Trac] #59234: Introduce a `wp_json_decode()` function, including validation when available
WordPress Trac
noreply at wordpress.org
Tue Mar 11 21:25:11 UTC 2025
#59234: Introduce a `wp_json_decode()` function, including validation when
available
--------------------------------------------+----------------------
Reporter: jrf | Owner: (none)
Type: enhancement | Status: closed
Priority: normal | Milestone:
Component: General | Version: 6.4
Severity: normal | Resolution: wontfix
Keywords: php83 needs-patch dev-feedback | Focuses:
--------------------------------------------+----------------------
Changes (by johnbillion):
* status: new => closed
* resolution: => wontfix
* milestone: Future Release =>
Comment:
Closing this off as per the comments above.
> Calling json_validate() immediately before json_decode() will
unnecessarily parse the string twice, as json_decode() implicitly performs
validation during decoding.
[attachment:"Perform_json_validate_before_json_decode_on_REST_API_request_data.patch"]
proposes calling `json_validate()` when parsing JSON parameters, but this
also immediately precedes a call to `json_decode()` making it redundant.
If there were a way to introduce a performant userland implementation of
`json_validate()` this would make sense as an enhancement for sites
running PHP 7, but there isn't.
If a particular scenario is introduced or identified where
`json_validate()` would make sense then that can be addressed as and when.
Cheers!
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59234#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list