mirror of https://github.com/MISP/PyMISPGalaxies
Add JSONEncoder
parent
2c1c2bb502
commit
9b8a387ab4
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from .api import Galaxies, Clusters
|
||||
from .api import Galaxies, Clusters, EncodeGalaxies
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue