Add JSONEncoder

pull/3/head
Raphaël Vinot 2017-07-25 18:21:23 +02:00
parent 2c1c2bb502
commit 9b8a387ab4
2 changed files with 10 additions and 1 deletions

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from .api import Galaxies, Clusters
from .api import Galaxies, Clusters, EncodeGalaxies

View File

@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
import json
from json import JSONEncoder
import os
import sys
import collections
@ -14,6 +15,14 @@ except ImportError:
HAS_JSONSCHEMA = False
class EncodeGalaxies(JSONEncoder):
def default(self, obj):
try:
return obj._json()
except AttributeError:
return JSONEncoder.default(self, obj)
class Galaxy():
def __init__(self, galaxy):