Daniel Ward added the comment:
I don't think I explained the response very well, effectively the __json__ call
would return an object which is JSON-serializable. This would include dict
objects containing JSON-serializable objects albeit natively-supporting JSON
serialisation or by mea
Daniel Ward added the comment:
Sure, so for example:
=
import json
class ObjectCounter:
def __init__(self, name, count):
self.name = name
self.count = count
def __json__(self):
return '[{name}] {count}'.format(name=self.name, count=
New submission from Daniel Ward:
To help prevent retrospective JSONEncoder overrides when failing to serialize a
given object, the intention of this issue is to propose that the JSON encoder
checks if a given object has a __json__ attribute, using that rather than
raising a TypeError.
This