array
The array
type represents a sequence of elements which have the same type.
array
has two parameters items
and length
:items
is used to indicate the type of the items in the array.length
is used to indicate the length of the array.name |
type |
required |
default |
description |
---|---|---|---|---|
|
JSON object |
True |
- |
- |
|
JSON string |
True |
- |
Represent the type of the items in the array. |
|
- |
False |
- |
Represent the type parameter of the items in the array. |
|
JSON integer |
False |
null |
Represent the length of the array,
used to define an array with a fixed length.
|
Examples:
an int32 array with unlimited length:
--- type: array items: type: int32
an int32 array with fixed length:
--- type: array items: type: int32 length: 2
a polygon represented by its vertex coordinates:
--- type: array items: type: record fields: - name: x type: int32 - name: y type: int32
when the item type is
record
, the behavior of anarray
will change to a table:Note
array
+record
= tableA
record
can be understood as a row in the table, thenarray
put many rows together to get a table.So the polygon array can be visually represented in table structure:
x
y
<x coordinate>
<y coordinate>
<x coordinate>
<y coordinate>
<x coordinate>
<y coordinate>
<x coordinate>
<y coordinate>
<x coordinate>
<y coordinate>
…
…