RESOLVED: TDJSON tuplet

In the wiki it says:

parameterToJSONPar(p, extraAttrs=None) → JSON object
Convert a parameter or tuplet to a jsonable python dictionary

In the textport it says:
td.Error: Parameter tuplets not supported.

Would be nice, if it’d work with tuplets, too.

Cheers, David

With the “opToJSONOp” command, it is possible to convert a tuplet to json,
but in some cases (when all parameters have the same setting) “min, max, normMin, normMax”, etc. return floats and in other cases (when those values differ) return lists.

I think it would be much cleaner, if those values are always inside a list with the same length as the tuplet, so we can index it without doing something like “if isinstance(parJson[‘min’], list):”

Cheers, David

Hi David

Regarding your first post, I couldn’t find the problem. The parameterToJSONPar works fine for me with tuplets. I suspect it is something else. If you have a 4 value parameter named “Float”, the code “oper.par.Float” will give the error you quoted. To get the tuplet (which is just a tuple of associated parameters), you can do “oper.par.Float1.tuplet”. That said, passing a single parameter from a tuplet, for example “parameterToJSONPar(oper.par.Float1)”, will return JSON for the entire tuplet. There is currently no way to get the JSON for a single parameter within a multi-par tuplet. Hope this helps. If not, send me your code or .toe file and I’ll look further.

Regarding your second post, I added a forceAttrLists argument to opToJSONOp, pageToJSONDict, and parameterToJSONPar. Set that to True to make all attributes that can have different values use lists as you requested. This will be in TouchDesigner in an upcoming release, but for now you can use the attached module if you want to experiment with it.
TDJSON.txt (12.5 KB)

PS I looked at your website… would love to visit the theatre you work at some day. I do theatre stuff with TD also.

Hi Ivan,

thank you four answers.

I was trying to do “parameterToJSONPar(op.par.Float)” and of course with “parameterToJSONPar(op.par.Float1)” it works :smiley:
And thank you for inlcuding the “forceAttrLists” argument as well.

You are welcome at our theatre any time and I’d be happy to give you a tour.
TD is slowly taking over this place :wink:
At the moment I use it for productions, that do not take place on one of the big stages, where we have expensive and clunky media servers, but I am working on a TD media server, that could replace them in the not so distant future.

Where are you doing your theatre work?

Best wishes,
David

Glad that helped out

The little tiny community theater I started in Oregon: www.opalcentercg.org