mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-08-06 02:21:42 +00:00
8 lines
296 B
Python
8 lines
296 B
Python
import simplejson
|
|
|
|
|
|
def safe_json_dumps(obj):
|
|
"""Safe version of json.dumps that also converts objects to dicts so they can be output, and ignores NaN floats
|
|
which are invalid in JSON."""
|
|
|
|
return simplejson.dumps(obj, ensure_ascii=False, ignore_nan=True, default=lambda o: o.__dict__) |