json_dump

compas.data.json_dump(data, fp, pretty=False, compact=False, minimal=False)[source]

Write a collection of COMPAS object data to a JSON file.

Parameters:
dataobject

Any JSON serializable object. This includes any (combination of) COMPAS object(s).

fppath string or file-like object

A writeable file-like object or the path to a file.

prettybool, optional

If True, format the output with newlines and indentation.

compactbool, optional

If True, format the output without any whitespace.

minimalbool, optional

If True, exclude the GUID from the JSON output.

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