Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json 无法在Avro架构1.7.7中指定用户定义的类型_Json_Avro - Fatal编程技术网

Json 无法在Avro架构1.7.7中指定用户定义的类型

Json 无法在Avro架构1.7.7中指定用户定义的类型,json,avro,Json,Avro,我正在试图找出为什么我不能在消息中使用媒体类型,avro模式: { "namespace": "com.ci.generated", "name": "MessageEnvelope", "type": "record", "fields": [{ "name": "message", "type": { "name": "Message", "type": "record",

我正在试图找出为什么我不能在
消息中使用
媒体类型
avro模式:

{
    "namespace": "com.ci.generated",
    "name": "MessageEnvelope",
    "type": "record",
    "fields": [{
        "name": "message",
        "type": {
            "name": "Message",
            "type": "record",
            "fields": [{
                    "name": "media_type",
                    "type": {
                        "type": "enum",
                        "name": "MediaTypes",
                        "symbols": ["Text", "Image"]
                    }
                },
                {
                    "name": "text_record",
                    "type": {
                        "type": "record",
                        "name": "TextRecords",
                        "fields": [{
                            "name": "name",
                            "type": "string"
                        }]
                    }
                },
                {
                    "name": "image_record",
                    "type": {
                        "name": "ImageRecords",
                        "type": "record",
                        "fields": [{
                                "name": "url",
                                "type": "string"
                            },
                            {
                                "name": "sentiment",
                                "type": {
                                    "name": "ImageSentiments",
                                    "type": "enum",
                                    "symbols": ["positive", "negetive", "neutral"]
                                }
                            }
                        ]
                    }
                },
                {
                    "name": "named_media",
                    "type": {
                        "name": "NamedMedia",
                        "type": "record",
                        "fields": [{
                                "name": "type",
                                "type": ["media_type"]
                            },
                            {
                                "name": "index",
                                "type": "int"
                            },
                            {
                                "name": "name",
                                "type": ["null", "string"]
                            },
                            {
                                "name": "data",
                                "type": [
                                    "null",
                                    "text_record",
                                    "image_record"
                                ]
                            }
                        ]
                    }
                }
            ]
        }
    }]
}
当我试图分析模式时,我遇到以下错误:

线程“main”org.apache.avro.SchemaParseException中的异常:未定义的名称:“媒体类型” 位于org.apache.avro.Schema.parse(Schema.java:1162) 位于org.apache.avro.Schema.parse(Schema.java:1272) 位于org.apache.avro.Schema.parse(Schema.java:1203)

我的身份是:
InputStream in=ClasName.class.getResourcesStream(“”);
Schema sc=new Parser().parse(in)


当我只使用json数据类型时,它工作得非常好。如何为设计的数据类型定义值?

我可以通过将数据更改为:

{"name": "data", "type": [
        "null",
        "TextRecord",
        "ImageRecords"
    ] 
}