marshalComplexMap static method

MarshalledObject marshalComplexMap(
  1. Map mapObject,
  2. IValueMarshallerFunction keyMarshaller,
  3. IValueMarshallerFunction valueMarshaller
)

Helper method.

Implementation

static MarshalledObject marshalComplexMap(Map mapObject, IValueMarshallerFunction keyMarshaller, IValueMarshallerFunction valueMarshaller)
{
  MarshalledObject marshalledMap = new MarshalledObject.emptyArray();
  MarshalledArray arrayAccessor = marshalledMap.asArray();

  /** serialise each key/value pair. */
  for (Object? key in mapObject.keys)
  {
    // Marshal key in odd position.
    arrayAccessor.pushElement( keyMarshaller(key).getRawValue() );
    // Marshal value in even position.
    arrayAccessor.pushElement( valueMarshaller( mapObject[key] ).getRawValue() );
  }

  return marshalledMap;
}