-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from Bernardo-MG/merge_master
Merge master
- Loading branch information
Showing
160 changed files
with
4,069 additions
and
851 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,5 @@ | |
:license: MIT, see LICENSE for more details. | ||
""" | ||
|
||
__version__ = '0.0.9' | ||
__version__ = '0.0.13' | ||
__license__ = 'MIT' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import json | ||
|
||
from cwr.parser.dictionary import CWRDictionaryEncoder | ||
from cwr.parser.common import Encoder | ||
|
||
|
||
""" | ||
Offers classes to parse CWR objects from and into JSON structures. | ||
""" | ||
|
||
__author__ = 'Bernardo Martínez Garrido' | ||
__license__ = 'MIT' | ||
__status__ = 'Development' | ||
|
||
|
||
class JSONEncoder(Encoder): | ||
def __init__(self): | ||
super(JSONEncoder, self).__init__() | ||
self._dict_encoder = CWRDictionaryEncoder() | ||
|
||
def encode(self, object): | ||
encoded = self._dict_encoder.encode(object) | ||
|
||
return json.dumps(encoded, default=_date_handler) | ||
|
||
|
||
def _date_handler(obj): | ||
if hasattr(obj, 'isoformat'): | ||
result = obj.isoformat() | ||
else: | ||
raise TypeError("Unserializable object {} of type {}".format(obj, | ||
type(obj))) | ||
|
||
return result |
Oops, something went wrong.