Export JSON (
Module containing a class for exporting a PySB model to JSON
For information on how to use the model exporters, see the documentation
A class for returning the JSON for a given PySB model.
pysb.export.Exporter, which implements basic functionality for all exporters.
Generate the corresponding JSON for the PySB model associated with the exporter.
- include_netgen: bool
Include cached network generation data (reactions, species, local function-derived parameters and expressions) if True.
The JSON output for the model.
PySBJSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)¶
Encode a PySB model in JSON
This encoder stores the model without caching the reaction network. To also store the reaction network, see
Attributes correspond to their PySB equivalents (monomers, parameters, etc.) and are mostly stored verbatim, with the following exceptions.
- MultiStates and the ANY and WILD state values use a special object format
- References to other components are stored using the component name
- Sympy expressions are encoded as strings using the default encoder
The protocol number (currently: 1) specifies semantic model compatibility, and should be incremented if new features are added which affect how a model is simulated or prevent a model being loaded by
Implement this method in a subclass such that it returns a serializable object for
o, or calls the base implementation (to raise a
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)
PySBJSONWithNetworkEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)¶
Encode a PySB model and its reaction network in JSON
This encoder stores the model including the cached reaction network. To encode the model without the reaction network, see
PySBJSONEncoder, which also includes implementation details.