Skip to content

ENH: make rocketpy classes json serializable #522

@Gui-FernandesBR

Description

@Gui-FernandesBR

Is your feature request related to a problem? Please describe.

Exporting rocketpy classes to a json file is something that the user currently cannot do so easily.
The get_instance_attributes (see below) function already made an important advance to export all the attributes of an instance to a dictionary, but that doesn't mean we can always save these dictionaries to json files.

Exporting objects as json files might be the easiest way of saving a rocketpy simulation without having to plot tons of data and plots.

def get_instance_attributes(instance):

Describe the solution you'd like

  • Add to_json, to_serializable or __json__ methods to the important classes of RocketPy, allowing the
  • Alternatively, the jsonpickle package can be used to perform a quick encode/decode with any of the rocketpy classes, as already done in the EnvironmentAnalysis class.
    def save(self, filename="env_analysis_dict"):

Additional context

As far as I know there's no convention on Python regarding the name of the method

Metadata

Metadata

Assignees

Labels

EnhancementNew feature or request, including adjustments in current codes

Type

No type

Projects

Status

Closed

Relationships

None yet

Development

No branches or pull requests

Issue actions