Skip to content

Php83::json_validate() - JSON_ERROR_INVALID_PROPERTY_NAME bug #533

@bkdotcom

Description

@bkdotcom

Symfony\Polyfill\Php83::json_validate() attempts to decode as an object (which faiils) / requires setting JSON_OBJECT_AS_ARRAY flag (not necessary with php's native function)

$json = json_encode(array(
    "\x00null" => 'JSON_ERROR_INVALID_PROPERTY_NAME',
    'string' => 'valid json, but must be decoded as an array,
));

json_decode($json, true); // success as array
json_decode($json, false); //  failure as obj

\Symfony\Polyfill\Php83::json_validate($json); // returns false
json_validate($json); // returns true

when using php's native json_validate, it is not necessary to set the JSON_OBJECT_AS_ARRAY flag

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions