acasown/webtech/encoder.py

10 lines
270 B
Python
Raw Permalink Normal View History

2019-04-14 16:04:33 +02:00
#!/usr/bin/env python
import json
class Encoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, set):
return list({"name": entry.name, "version": entry.version} for entry in obj)
return json.JSONEncoder.default(self, obj)