未使用布尔值的默认值

问题描述 投票:0回答:1

我有一个这样的avro模式,其中我捕获了以boolean表示的十进制值,我想为它提供默认值true,所以我想出了以下avro模式。

   {
    "namespace": "abc",
    "type": "record",
    "name": "Request",
    "fields": [
        {
            "name": "amount",
            "type": "long",
        },
        {
            "name": "currency",
            "type": ["string", "null"],
        },
        {
            "name": "capture",
            "type": "boolean",
            "default": true
        } 
}

在Java中使用时,它将获得默认值null我需要怎么做才能将其默认设置为true

我有一个这样的avro模式,其中我捕获了以boolean表示的十进制值,我想将默认值设置为true,因此我提出了以下avro模式。 {“ namespace”:“ abc”,“ ...

boolean default avro
1个回答
0
投票

这不仅与Java有关。一般而言(根据https://avro.apache.org/docs/current/spec.html中提供的文档),我们有:

© www.soinside.com 2019 - 2024. All rights reserved.