src/Component/Json.php
/**
     * Validates a string as a JSON string.
     *
     * @param string $value
     * @param bool $assoc To return decoded JSON as associative array or not.
     * @return array An array of two values:
     * [0]: Is the string a valid JSON or not,
     * [1]: The decoded JSON string, or null if either the string is not a valid JSON or an
     * error occurred while decoding it.
     */
Validates a string as a JSON string.
@param string $value
@param bool $assoc To return decoded JSON as associative array or not.
@return array An array of two values:
[0]: Is the string a valid JSON or not,
[1]: The decoded JSON string, or null if either the string is not a valid JSON or an
error occurred while decoding it.
Validates a string as a JSON string . @param string $value @param bool $assoc To return decoded JSON as associative array or not . @return array An array of two values : [ 0 ] : Is the string a valid JSON or not [ 1 ] : The decoded JSON string or null if either the string is not a valid JSON or an error occurred while decoding it .
protected static function validateStringAsJson(string $value, bool $assoc = false): array
    {
        try {
            $decodedValue = self::decodeJson($value, $assoc);
        } catch (JsonException $e) {
            return [false, null];
        }
        return [true, $decodedValue];
    }
protected static function validateStringAsJson ( string $ value , bool $ assoc = false ) : array { try { $ decodedValue = self :: decodeJson ( $ value , $ assoc ) ; } catch ( JsonException $ e ) { return [ false , null ] ; } return [ true , $ decodedValue ] ; }
Validates a string as a JSON string.
Validates a string as a JSON string .