protected function serialize($data)
    {
        if ('' === trim($data)) {
            return null;
        }

        if (null === $result = json_decode($data, true)) {
            if (json_last_error() !== JSON_ERROR_NONE) {
                throw new ReadException(json_last_error_msg(), json_last_error());
            }
        }

        return new ParameterBag($result);
    }