json_dumps

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

Write a collection of COMPAS objects to a JSON string.

Parameters:
dataobject

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

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:
str

Examples

>>> import compas
>>> from compas.geometry import Point, Vector
>>> data1 = [Point(0, 0, 0), Vector(0, 0, 0)]
>>> s = compas.json_dumps(data1)
>>> data2 = compas.json_loads(s)
>>> data1 == data2
True