json_dump
- compas.data.json_dump(data, fp, pretty=False)[source]
Write a collection of COMPAS object data to a JSON file.
- Parameters
data (object) – Any JSON serializable object. This includes any (combination of) COMPAS object(s).
fp (path string or file-like object) – A writeable file-like object or the path to a file.
pretty (bool, optional) – If True, format the output with newlines and indentation.
- Returns
None
Examples
>>> import compas >>> from compas.geometry import Point, Vector >>> data1 = [Point(0, 0, 0), Vector(0, 0, 0)] >>> compas.json_dump(data1, 'data.json') >>> data2 = compas.json_load('data.json') >>> data1 == data2 True