ofParameter to ofJson

Hi all!

I would like to know how is the current status of saving ofParameters to JSON
format. Is it already implemented? otherwise, is it in the roadmap?

As far as I can see ofxXML has this serialize() function to stringify all parameters of a ofParameterGroup. But I see that so far ofJson is just a rename of nlohmann::json which obviously does not implement such method.

Any fast advice to get ofParameters save/load to JSON ?


Hi, I haven’t tried this at all, but I saw these JSON related commits on the openframeworks master from Arturo:



Thank you @hahakid !

I was looking at ofxJsonSettings but I wanted to avoid addons since there are many versions of ofxJSON out there.

I will give it a try :slight_smile:
Thank you again!

yes if you are in master using ofxGui you can just set the file to save to as .json and it’ll use ofJson automatically

Thank you @arturo
And if I’m not using ofxGui? is there any plans to move this feature to ofParameterGroup? or am I asking something stupid ?

you can also do something like:

ofJson json;
ofSerialize(parameterGroup, json);
ofSaveJson("settings.json", json);

And the same with ofXml

1 Like

oh great! that’s what I was looking for!
Thank you so much!

hey, I am trying to store easily my app data from a “vector of variables/ofParameters inside an struct” to a json/xml file.
My data is something like this:

struct PRESET_Struct {
		float ADSR_ATTACK;
		float OUT_frequency;
		bool OUT_TAP;
		bool OUT_ENV;
		bool OUT_BPM_TAP;
		bool LFO_ENABLE;
		bool LFO_STATE;
		int LFO_timeCycle;
	PRESET_Struct myPreset;
	vector <PRESET_Struct> myKit;

I found this two addons based on https://msgpack.org/:

But I can’t make them work yet, and I don’t know if there’s any new OF core method to do this.
I still using 0.9.8 and VS2015