-
Notifications
You must be signed in to change notification settings - Fork 2
Object Structure
The logical structure of a serialized object is as follows:
An object is an unordered set of key/value pairs enclosed in a start-object and end-object delimiter.
object
start-object *(key value) end-object
A key is an integer value.
key
integer
A value can be a nested object, an array, or a primitive.
value
object
array
primitive
An array is an ordered collection of values enclosed in a start-array and an end-array delimiter.
array
start-array *value end-array
A primitive is an octets value (byte array), a Unicode string value, an integer, a float, a Boolean true or false, or a null value.
primitive octets string integer float true false null
That's it! The serialized representations of the undefined elements is determined by the specific encoding chosen at runtime.
The logical structure of a serialized object is almost identical to JSON, with the following exceptions:
-
The top-level element MUST be
object. JSON allows the top-level element to be a bare value (which is never a good idea, so I'm just taking that gun away from you). -
Member key types are integers as opposed to strings in JSON. This is a trade-off between human readability and protocol efficiency, and the winner here is efficiency.
-
JSON does not have an
octetsprimitive type, so byte arrays must be converted to strings.
All of the differences from JSON apply, and additionally:
- Serialized objects do not have the equivalent of XML attributes.