Skip to content

Conversation

@deguif
Copy link
Collaborator

@deguif deguif commented Dec 7, 2022

No description provided.

@deguif deguif force-pushed the remove-json-util branch 2 times, most recently from d7fd542 to 114e5ca Compare December 7, 2022 13:54
@sidz
Copy link
Collaborator

sidz commented Dec 7, 2022

my 2 cents: what about to no remove JSON class and improve it instead to smth like:

class JsonEncoder
{
    private function __construct()
    {
    }

    public static function encode(mixed $value, int $flags = null, int $maxDepth = 512): string
    {
        $flags ??= \JSON_HEX_TAG | \JSON_HEX_APOS | \JSON_HEX_AMP | \JSON_HEX_QUOT | \JSON_PRESERVE_ZERO_FRACTION;

        try {
            return json_encode($value, $flags | \JSON_THROW_ON_ERROR, $maxDepth);
        } catch (\JsonException $e) {
            throw new InvalidArgumentException('Invalid value for "json" option: '.$e->getMessage());
        }
    }

and the same for json_decode.

The idea is pretty simple - tons of json_encode(decode) around the codebase

@ruflin
Copy link
Owner

ruflin commented Jul 25, 2025

@sidz @deguif Thoughts on a path forward here for 9.x?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants