I have a dictionary
data_msg = {'id1': [{'id2': ['message_obj', 'message_obj1']}, {'id3': ['message_obj', 'message_obj1']}], '247217277613768704': [{'247217277613768704': [<Message id=747569642603806861 channel=<TextChannel id=745834933808791603 name='verification' position=5 nsfw=False news=False category_id=619309021316513794> type=<MessageType.default: 0> author=<Member id=745497933662650369 name='Rep' discriminator='5005' bot=True nick=None guild=<Guild id=619309021316513792 name='Strictly Coaching' shard_id=None chunked=True member_count=10>> flags=<MessageFlags value=0>>]}]}
My code is as follows:
pend = 'bin/pending'
v_repped = 'bin/verified_repped'
message_bin = 'bin/message_bin'
def on_instance(data_instanced):
if data_instanced == data:
data_main = json.dumps(data_instanced)
with open(pend, 'w') as instance:
json.dump(data_main, instance)
elif data_instanced == data_verified:
data_v = json.dumps(data_instanced)
with open(v_repped) as instance:
json.dump(data_v, instance)
elif data_instanced == data_msg:
data_m = json.dumps(data_instanced)
with open(message_bin) as instance:
json.dump(data_m, instance)
Where data_msg, data_verified, and data are global variables to store dictionaries. I went ahead and gave the data for "data_msg" as that seems to be the one that is not working.
The error I get is as follows: TypeError: Object of type Message is not JSON serializable