ofDeserialize ofParameterGroup in specific odrer

I thought this question has been answered but i can’t manage to hit the right keyword.
I’m looking for a way to specify priority order when loading a group of saved settings.
I have the constraint that some parameters must be loaded before others.

Also I was wondering how the serializer behaves when things might go wrong:

  • loading a group of parameters stored on a file to an ofParameter group when they do not match in number or name.
  • saving to a file. Does it always override? is it possible to update certain group of parameters keeping the rest untouched.

Any lights are very welcome :slight_smile:

you would need to save them in that order then or manually load each parameter instead of letting ofDeserialize deserialize the whole group

  • loading a group of parameters stored on a file to an ofParameter group when they do not match in number or name.

It just does nothing with the parameters which names are not in the group

  • saving to a file. Does it always override? is it possible to update certain group of parameters keeping the rest untouched.

Yes, it always override, again if you need something more fine grained you need to manually serialize the parameters you want to serialize and leave the rest out

1 Like

As an example, if you want to only save velocity and acceleration from a full group with name settings:

ofJson json = ofLoadJson("settings.json");
ofSerialize(json["settings"]["velocity"], settings["velocity"]);
ofSerialize(json["settings"]["acceleration"], settings["acceleration"])
ofSaveJson("settings.json", json);

haven’t tested so the syntax might be slightly different but i guess you get the idea

1 Like

Thank you so much! that makes it very clear.