serializationrtmpamfabnf

What is the proper way to encode an AMF0 StrictArray


After overviewing the AMF0 specification I find that I cannot understand the proper way to encode the StrictArray type.

Here is the most immediate section of the specification:

array-count = U32

strict-array-type = array-count *(value-type)

which describes the StrictArray type with Augmented Backus-Naur Form (ABNF) syntax (See RFC2234)

Does the StrictArray type have ordinal indices or simply encoded objects (without ordinal keys) in order of their appearance in the StrictArray object graph?

Also, as an additional question, does the serialization table (from which object reference IDs are generated) contain all objects in the object graph, or only objects which can be potentially encoded via reference (ECMAArray,StrictArray,TypedObject,AnonymousObject)?


Solution

  • See https://github.com/silexlabs/amfphp-2.0/blob/master/Amfphp/Core/Amf/Serializer.php line 329 to 336. you write the number of objects, then each object.

    additional question: same code, look for Amf0StoredObjects. references ids are only for referencable objects. These vary for AMF0 and AMF3 though.