code: def pack_dict(obj):
      
      obj = OrderedDict(obj)
      blob = b'S'
      blob += np.array((1, 1), dtype=np.uint64).tostring()
      blob += np.array(len(obj), dtype=np.uint32).tostring()
  
      # write out field names
      for k in obj:
          blob += pack_string(k)
  
      for k, v in obj.items():
          blob_part = pack_obj(v)
          blob += np.array(len(blob_part), dtype=np.uint64).tostring()
          blob += blob_part
  
      return blob
docs: Write dictionary object as a singular structure array
      :param obj: dictionary object to serialize. The fields must be simple scalar or an array.