@RafaelA ,
Data Collections can be serialized to/from a dictionary or JSON but the honeybee serialization components are only meant for serializing honeybee objects. You can do the serailization to JSON with the following code:
import json
a = 'C:/ladybug/data_collection.json'
obj_dict = [data.to_dict() for data in x]
with open(a, 'w') as fp:
json.dump(obj_dict, fp)
And here’s how you can re-serialize it back:
from ladybug.datacollection import HourlyDiscontinuousCollection
import json
with open(x) as json_file:
all_data = json.load(json_file)
a = [HourlyDiscontinuousCollection.from_dict(data) for data in all_data]
Here’s a sample file:
DataCollection_Serialization.gh (22.5 KB)