JsonSerializationMixin¶
-
class
lsst.verify.jsonmixin.JsonSerializationMixin[source]¶ Bases:
objectMixin that provides JSON serialization support to subclasses.
Subclasses must implement the
jsonmethod. The method returns adictthat can be serialized to JSON. Use thejsonify_dictmethod to handle the conversion of iterables, numbers, strings, booleans andJsonSerializationMixin-compatible objects into a JSON-serialiable object.Attributes Summary
jsondictthat can be serialized as semantic JSON, compatible withMethods Summary
jsonify_dict(d)Recursively build JSON-renderable objects on all values in a dict. write_json(filepath)Write JSON to a file. Attributes Documentation
Methods Documentation
-
static
jsonify_dict(d)[source]¶ Recursively build JSON-renderable objects on all values in a dict.
Parameters: d :
dictDictionary to convert into a JSON-serializable object. Values are recursively JSON-ified.
Returns: json_dict :
dictDictionary that can be serialized to JSON.
Examples
Subclasses can use this method to prepare output in their
json-method implementation. For example:def json(self): return JsonSerializationMixin.jsonify_dict({ 'value': self.value, })
-
static