public boolean readBoolean() throws IOException {
        int code = readNextCode();

        switch (code) {
            case Codes.TRUE:
                return true;
            case Codes.FALSE:
                return false;
            default: {
                Object result = read(code);
                if (result instanceof Boolean) {
                    return (Boolean) result;
                } else {
                    throw expected("boolean", code, result);
                }
            }
        }
    }