Skip to content

Latest commit

 

History

History
11 lines (9 loc) · 455 Bytes

line2json.rst

File metadata and controls

11 lines (9 loc) · 455 Bytes

Save an Xtrack Line to a json file

An Xtrack Line object can be transformed into a dictionary and saved in a json file, as illustrated in the following example. Note that xobjects.JEncoder needs to be provided to json.dump in order to serialize Numpy arrays, which are not natively supported by json.

.. literalinclude:: generated_code_snippets/tojson.py
   :language: python