jchanvfx / NodeGraphQt

Node graph framework that can be re-implemented into applications that supports PySide2
http://chantonic.com/NodeGraphQt/
MIT License
1.29k stars 264 forks source link

NodeGraph.save_session cannot serialize sets #356

Closed snorthman closed 1 year ago

snorthman commented 1 year ago

NodeGraph.save_session(str) does not work, as it cannot serialize set objects.

Here is where a set occurs in my serialized session:

unserializable: set = serialized['graph']['accept_connection_types']['simulator.SimulatorNode']['in']['sim']['simulator.SimulationNode']['out']

Two easy solutions, rather than avoid sets in serialization:

stackoverflow SetEncoder

or

def serialize_json(obj):
  if isinstance(obj, set):
    return list(obj)
  return obj

json.dumps(text, default=self.serialize_json)
jchanvfx commented 1 year ago

addressed in v0.6.10 thanks for catching that bug 😺