     buf = new Buffer [ 0x0a ]  # strict-array-marker
     buf = createAMF0StrictArray data, buf
   else if type is 'object'
-    count = Object.keys(data).length
-    buf = new Buffer [
-      # ecma-array-marker
-      0x08,
-      # array-count
-      (count >>> 24) & 0xff,
-      (count >>> 16) & 0xff,
-      (count >>> 8) & 0xff,
-      count & 0xff
-    ]
-    buf = createAMF0ECMAArray data, buf
+    buf = createAMF0Object data
   else
     throw new Error "Unknown data type \"#{type}\" for data #{data}"
   buf

                  outputs.push output
                seq.done()
            when 18  # AMF0 data message
              dataMessage = parseAMF0DataMessage rtmpMessage.body
              if DEBUG_INCOMING_RTMP_PACKETS
                logger.info "[rtmp:receive] AMF0 data:"
                logger.info dataMessage
              @handleAMFDataMessage dataMessage, (err, output) ->
                if err?
                  logger.error "[rtmp:receive] packet error: #{err}"
                if output?
                  outputs.push output
                seq.done()
            when 20  # AMF0 command
              commandMessage = parseAMF0CommandMessage rtmpMessage.body
              if DEBUG_INCOMING_RTMP_PACKETS


createAMF0Object = (obj) ->
  buf = new Buffer [ 0x03 ]  # object-marker
  return createAMF0PropertyList obj, buf

createAMF0ECMAArray = (obj) ->
  count = Object.keys(obj).length
  buf = new Buffer [
    # ecma-array-marker
    0x08,
    # array-count
    (count >>> 24) & 0xff,
    (count >>> 16) & 0xff,
    (count >>> 8) & 0xff,
    count & 0xff
  ]
  return createAMF0PropertyList obj, buf

createAMF0PropertyList = (obj, buf=null) ->
  bufs = []
  totalLength = 0
  if buf?
