无法验证具有可选值的AVRO模式。

huangapple go评论88阅读模式
英文:

Can't validate AVRO schema with optional value

问题

我有这个AVRO模式:

现在当我尝试验证一些数据时,这个有效:

但这个不起作用!

为什么?我真的搞不清楚。

英文:

I have this AVRO schema:

  1. {
  2. "type": "record",
  3. "name": "SelectActiveApp",
  4. "fields": [
  5. {
  6. "name": "eventName",
  7. "type": "string"
  8. },
  9. {
  10. "name": "eventData",
  11. "type": {
  12. "type": "record",
  13. "name": "EventData",
  14. "fields": [
  15. {
  16. "name": "appId",
  17. "type": ["null", "string"],
  18. "default": null
  19. }
  20. ]
  21. }
  22. }
  23. ]
  24. }

Now when I try to validate some data, this works:

  1. {
  2. "eventName": "active-app-selected",
  3. "eventData": {
  4. "appId": null
  5. },
  6. }

But this is not working!

  1. {
  2. "eventName": "active-app-selected",
  3. "eventData": {
  4. "appId": "any string"
  5. },
  6. }

Why? I really can't figure it out.

答案1

得分: 1

{
"eventName": "active-app-selected",
"eventData": {
"appId": { "string": "某些字符串" }
}
}

英文:

Try this

  1. {
  2. "eventName": "active-app-selected",
  3. "eventData": {
  4. "appId": { "string": "some string"}
  5. }
  6. }

huangapple
  • 本文由 发表于 2023年6月15日 14:44:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/76479793.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定