| Data Type |
Encoding |
JS API output |
Description |
Boolean |
1 bit |
true|false |
0=true, 1=false |
Integer (fixed length of x) |
x bit |
Number |
A fixed amount of bit representing an integer. Usual lengths are 3, 6 or 12 bit.
Example: int(6) “000101” represents the number 5 |
Integer (Fibonacci) |
Variable Length |
Number |
Integer encoded using Fibonacci encoding
See “About Fibonacci Encoding” for more detail |
String (fixed length of x) (including country codes) |
x*6 bit |
String |
A fixed amount of bit representing a string. The character’s ASCII integer ID is subtracted by 65 and encoded into an int(6).
Example: int(6) “101010” represents integer 47 + 65 = char “h” |
Datetime |
36 bit |
Date |
A datetime is encoded as a 36 bit integer representing the 1/10th seconds since January 01 1970 00:00:00 UTC.
Example JavaScript representation: Math.round((new Date()).getTime()/100) |
Bitfield (fixed length of x) |
x bit |
Array of Number |
A fixed amount of bit. Usually each bit represents a boolean for an ID within a group where the first bit corresponds to true/false for ID 1, the second bit corresponds to true/false for ID 2 and so on. |
N-bitfield (Variable length Bitfield) |
variable |
Array of Number |
Consists of two datapoints: a fixed length Integer(16) that denotes the length and a bitfield with that specific length.
Please note: Although the API reads/writes to fields (length + bitfield), it will only output the IDs from the bitfield via JS APIs. |
Range (Int) |
variable |
Array of Number |
A range field always consists of the following fields:
- int(12) - representing the amount of items to follow
- (per item) Boolean - representing whether the item is a single ID (0/false) or a group of IDs (1/true)
- (per item) int(16) - representing a) the single ID or b) the start ID in case of a group
- (per item + only if group) int(16) - representing the end ID of the group
Example:
- int(12) = 2 // 2 items
- Bool = 0 // item 1 is type single ID
- int(16) = 3 // ID of item 1
- Bool = 1 // item 2 is type group
- int(16) = 5 // item 2 start ID
- int(16) = 8 // item 2 end ID
- Range = [3,5,6,7,8]
- Bits = 000000000010 0 0000000000000011 1 0000000000000101 0000000000001000
Note: items may not be in sorted order. |
Range (Fibonacci) |
variable |
Array of Number |
A range field always consists of the following fields:
- int(12) - representing the amount of items to follow
- (per item) Boolean - representing whether the item is a single ID (0/false) or a group of IDs (1/true)
- (per item) int(Fibonacci) - representing a) the offset to a single ID or b) the offset to the start ID in case of a group (the offset is from the last seen number, or 0 for the first entry)
- (per item + only if group) int(Fibonacci) - length of the group
Example:
- int(12) = 2 // 2 items
- Bool = 0 // item 1 is type single ID
- int(Fibonacci) = 3 // ID of item 1
- Bool = 1 // item 2 is type group
- int(Fibonacci) = 2 // offset to last ID (3+2 = 5 is first ID)
- int(Fibonacci) = 3 // length of group (5+3 =>8 is last ID)
- Range = [3,5,6,7,8]
- Bits = 000000000010 0 0011 1 011 0011
Note: items MUST be in sorted order.. |
OptimizedRange |
variable |
Array of Number |
Consists of two data types:
- First data type is always a Boolean.
- If the first data type is 1/true, the second data type is a Fibonacci Range
- If the first data type is 0/false, the second data type is a Variable length bitfield.
Please note: although the API reads/writes multiple fields, the API will only return the array of found IDs |
OptimizedIntRange |
variable |
Array of Number |
Consists of three data types:
- First data type is an Integer (fixed length of 16 bit).
- Second data type is always a Boolean.
- If the second data type is 1/true, the third data type is an Int Range
- If the second data type is 0/false, the second data type is a bitfield of length determined by the first data type (see above)
Note: This data type is used for downward compatibility only. OptimizedRange is the recommended data type to be used moving forward. |
ArrayOfRanges |
variable |
[{'key':number, 'type':number, 'ids':Array of number}, {...}, ...] |
Consists of a variable amount of fields:
- First field is always of type Int(12). The value indicates the number of records to follow.
- Each entry consists of three datatypes:
- key - Int(6)
- type - Int(2)
- ids -
OptimizedIntRange (uses Range(Int) for range of IDs, see OptimizedIntRange data type above for more details)
Note: ArrayOfRanges is used for downwards compatibility only. |
N-ArrayOfRanges(X,Y) |
variable |
[{'key':number, 'type':number, 'ids':Array of number}, {...}, ...] |
Consists of a variable amount of fields:
- First field is always of type Int(12). The value indicates the number of records to follow.
- Each record consists of three datatypes:
- key - Int(X) Where X is given by the field definition within the corresponding specification.
- type - Int(Y) Where Y is given by the field definition within the corresponding specification.
- ids -
OptimizedRange (uses Fibonacci coding for range of IDs, see OptimizedRange data type above for more details)
|
When defining a new section, regional policy writers should consider the above format to describe their section. Policy writers must ensure that each field within the section has a name that is unique for this section. When using multiple sub-sections within the section, field names with similar meanings (such as "type" or "version") shall be prefixed in order to be unique for the section (e.g. "coreVersion" and "publisherVersion").