Please sign in to comment.
Make JSON encoder extension point clear, and call super() properly fr…
…om decoder. Remove from_python(). Fix #42, #44. We move JsonEncoder out to the module level and transplant the guts of from_python into JsonEncoder.default(). This makes it possible to call super() from the decoder, which would be very awkward from from_python(). The way to make the decoder aware of new types is now to subclass our JsonEncoder and stick your new class into an ElasticSearch object's json_encoder attr. We take advantage of the new design to call super() from the decoder, which leads us raise a TypeError on unexpected input, as is usual with the json module, rather than a ValueError or other error.
- Loading branch information...
Showing with 15 additions and 19 deletions.