我的avro模式中有一个关于favorite_number的联合,它可以是null或int类型。当我对对象进行json编码时,得到以下结果:
{"name": "Alyssa", "favorite_number": {"int": 7}, "favorite_color": null}
我想要去掉联合类型指示器,即int,在这种情况下,使其变为:
{"name": "Alyssa", "favorite_number": 7, "favorite_color": "blue"}
avro模式:
{"name": "person", "type": "record",
"fields": [
{"name": "name", "type": "string"},
{"name": "favorite_number", "type": ["null", "int"], "default": null},
{"name": "favorite_color", "type": "string"}
]
}
有没有办法做到这一点?谢谢!
org.apache.avro.util.RandomData(schema, 1).iterator()
从avsc生成随机数据到JSON示例,但它不包括类型指示器。 - undefined