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

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

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"}
  }
}

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:

确定