You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2020-12-30.20:22:51.914>labels= ['library']
title='There is no way to json encode object to str.'updated_at=<Date2021-08-31.20:34:24.741>user='https://bugs.python.org/kaltovichartyom'
At first I want to say thank you for all your efforts in python development. I really appreciate it. :)
I am trying to convert custom object to json.
But, I've found a problem. JSONEncoder has default method for converting custom objects to some primitives and encode for converting structures.
But what if I want to return completed json string? I can't do it in default, because JSONEncoder will think it is string and encode it accordingly later in iterencode method.
Then I tried redefine encode, but it is called with the dict(array_name=default(o)) so I should convert the dict as a whole and basically reimplement all conversions (for int, float, and lists of course).
Did I missed something or there is no way to do it?
I suggest to introduce another method, e.g. encode_obj and call it there:
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: