@namespace ("example")
protocol ExampleProtocol {
// An opaque type is in fact a byte array of a fixed length.
fixed LongLongInteger (8);
// Enum types are integers and can have default value.
enum SomeEnum { ONE, TWO, THREE } = THREE;
record SomeRecord {
// This is really only useful in unions.
null aNullField;
// The usual primitive types.
boolean aBoolean;
int aSigned32BitInteger;
long aSigned64BitInteger;
float aFloat = 0.0;
double aDouble;
bytes someBytes;
/** This is in fact a doc string. */
string
@aliases (["anOriginalString", "anEvenMoreOriginalString"])
aString = "This used to have some other names but not now.";
// Logical types are supported on top of some standard types.
@logicalType ("unsignedLong")
long anUnsigned64BitInteger;
@logicalType ("decimal")
@precision (8)
@scale (2)
bytes aFixedDecimalPointNumber;
@logicalType ("UUID")
string anUUID;
// Nested records with optional presence.
SomeRecord? nextRecord;
// The usual complex types.
array<string> aStringList = [];
map<int> aStringToIntMap = { "key" : 0xBAAD };
union { null, int } anotherOptionalDeclaration = null;
@deprecated (true)
int aDeprecatedInteger = 0;
LongLongInteger aLongLongInteger;
SomeEnum anEnumValue;
}
// Guess how this would get serialized :-)
record TestRecord { TostRecord r; }
record TostRecord { TestRecord r; }
}
All fields required or with default value
Typical basic and constructed types
Namespaces and anonymous types
Primary format is JSON