英文:
Can't validate AVRO schema with optional value
问题
我有这个AVRO模式:
现在当我尝试验证一些数据时,这个有效:
但这个不起作用!
为什么?我真的搞不清楚。
英文:
I have this AVRO schema:
{
"type": "record",
"name": "SelectActiveApp",
"fields": [
{
"name": "eventName",
"type": "string"
},
{
"name": "eventData",
"type": {
"type": "record",
"name": "EventData",
"fields": [
{
"name": "appId",
"type": ["null", "string"],
"default": null
}
]
}
}
]
}
Now when I try to validate some data, this works:
{
"eventName": "active-app-selected",
"eventData": {
"appId": null
},
}
But this is not working!
{
"eventName": "active-app-selected",
"eventData": {
"appId": "any string"
},
}
Why? I really can't figure it out.
答案1
得分: 1
{
"eventName": "active-app-selected",
"eventData": {
"appId": { "string": "某些字符串" }
}
}
英文:
Try this
{
"eventName": "active-app-selected",
"eventData": {
"appId": { "string": "some string"}
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论