3

I have objects message of type azure.servicebus.common.message.Message. I can print it and get representation that looks like dictinorary.

print(message)
{b'Type': b'TEST', b'Subtype': b'subtype'}
print(type(message))
<class 'azure.servicebus.common.message.Message'>
print(dict(message))
TypeError: 'Message' object is not iterable

I would like to add dictionary representation of this object to the list, not the object like below

batch.append(message)

How to convert representation of the object to dictionary ?

irom
  • 3,316
  • 14
  • 54
  • 86
  • 1
    Doesn't `dict(message)` (or `str(message)`) work? It is unclear to me what do you mean by *"dictionary representation"*. – norok2 Oct 02 '19 at 14:19
  • 1
    @DeepSpace what you are looking at is not a dict, but rather as the OP says a "representation that looks like dictionary". @irom I agree it seems that a dictionary (or something like one) is being used internally, perhaps you can check how `Message.__str__` is implemented to find out where it comes from? – myrtlecat Oct 02 '19 at 14:38

0 Answers0