json_dumps
-
compas.
json_dumps
(data, pretty=False)[source] Write a collection of COMPAS objects to a JSON string.
- Parameters
data (any) – Any JSON serializable object. This includes any (combination of) COMPAS object(s).
pretty (bool, optional) –
True
to format the output with indentation, otherwiseFalse
.
- 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