6.1.1.3.1.4. pytfa.io.json
¶
JSON serialization
6.1.1.3.1.4.1. Module Contents¶
6.1.1.3.1.4.1.1. Classes¶
|
We define an encoder that takes care of the serialization of numpy types, |
6.1.1.3.1.4.1.2. Functions¶
|
|
|
|
|
|
|
Returns a JSON dump as a string |
|
Loads a model from a string JSON dump |
- class pytfa.MyEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)¶
Bases:
json.JSONEncoder
We define an encoder that takes care of the serialization of numpy types, which are not handled by json by default
- default(self, obj)¶
Implement this method in a subclass such that it returns a serializable object for
o
, or calls the base implementation (to raise aTypeError
).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o)
- pytfa.check_json_extension(filepath)¶
- pytfa.save_json_model(model, filepath)¶
- pytfa.load_json_model(filepath)¶
- pytfa.json_dumps_model(model)¶
Returns a JSON dump as a string
- Parameters
model –
- Returns
- pytfa.json_loads_model(s)¶
Loads a model from a string JSON dump
- Parameters
s – JSON string
- Returns