Arvo的Scheme规范

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/eieiei438/article/details/81635115

Arvo的Scheme规范

语法格式

  • JSON格式

支持的【简单】类型

  1. null------------no value
  2. boolean---------a binary value
  3. int ------------32 bit signed integer
  4. long------------64 bit signed integer
  5. float-----------single precision (32 bit)
  6. double----------double precision (64 bit)
  7. bytes-----------sequence of 8-bit unsigned bytes
  8. string----------unicode character sequence

支持的【复杂】类型

  1. records
  2. enums
  3. arrays
  4. maps
  5. unions
  6. fixed

例子

  • 备注
    1. name---名称
    2. namespace---路径名称
    3. doc---文档注释
    4. aliases---别名
    5. fileds---包含项
    6. type---类型
    7. default---默认值
    8. symbols---枚举常量
序号 复杂类型 要求 例子
1 Records
        "type":"record"

    参数要求:

        1、name【必须】

        2、namespace

        3、doc【可选】

        4、aliases【可选】

        5、fields【必须】

                1、name【必须】

                2、doc【可选】

                3、type【必须】

                4、default【可选】
{
"type": "record",
"name": "LongList",
"aliases": ["LinkedLongs"],
fields" : [
  {"name": "value", "type": "long"},
  {"name": "next", "type": ["null", "LongList"]}
]
}
2 Enums
        "type":"enum"

    参数要求:

        1、name【必须】

        2、namespace

        3、doc【可选】

        4、aliases【可选】

        4、symbols【必须】
{
"type": "enum",
"name": 
"Suit",
"symbols" : ["SPADES", "HEARTS", "DIAMONDS", "CLUBS"]
}
3 Arrays
        "type":"array"

    参数要求:

        1、items【必须--写子项的类型】
{"type": "array", "items": "string"}
4 Maps
        "type":"map"

    参数要求:

        1、values【必须--写子项的类型】
{"type": "map", "values": "long"}
5 Unions 类型:JSON上数组【Unions不能包含多个相同类型的Schema,除非是命名的record类型、命名的fixed类型和命名的enum类型】 ["null","string"]
6 Fixed
        "type":"fixed"

    参数要求:

        1、name【必须】

        2、namespace

        3、size【必须】

        4、aliases【可选】
{"type": "fixed", "size": 16, "name": "md5"}

复杂用法

猜你喜欢

转载自blog.csdn.net/eieiei438/article/details/81635115