Hello,
I’ve been playing with TDJSON for a while now (more than a year I believe) for a personal project. I went back to testing it every build since early 2019, and it seems that it is still not fully bug-free.
In the release notes of 2020.20020, it is advertised that:
TDJSON updated and bugs fixed.
- All functions now work with built-in parameters.
- Added a deserializer TDData function to TDJSON.
Unfortunately, not all functions work with built-in parameters.
The main problem seems to be with the extraAttrs argument (of any function).
For example, calling the following few lines on COMPs or Pars will work just fine:
TDJ.opToJSONOp(comp, forceAttrLists=True, includeCustomPages=True, includeBuiltInPages=True)
or the straightforward
TDJ.parameterToJSONPar(parameter, forceAttrLists=True)
Now, calling the followings
TDJ.opToJSONOp(n, extraAttrs=ATTR_LIST, forceAttrLists=True, includeCustomPages=True, includeBuiltInPages=True)
or TDJ.parameterToJSONPar(parameter, extraAttrs=ATTR_LIST, forceAttrLists=True)
where ATTR_LIST is the following constant string-array, of all the attributes that I know of:
ATTR_LIST = [
'valid',
'val',
'expr',
'exportOP',
'exportSource',
'bindMaster',
'tuplet',
'prevMode',
'owner',
'bindExpr',
'bindReferences',
'index',
'vecIndex',
'name',
'label',
'startSection',
'displayOnly',
'readOnly',
'tupletName',
'min',
'max'
'clampMin',
'clampMax',
'default',
'defaultExpr',
'normMin',
'normMax'
'normVal',
'enable',
'order',
'page',
'password',
'mode',
'menuNames',
'menuLabels',
'menuIndex',
'menuSource'
]
will cause an exception:
Traceback (most recent call last):
File "</BananaGit/text2:op('/BananaGit/text2').run()>", line 1
td.Error: File "/BananaGit/text2", line 1
File "/BananaGit/BananaGitExt", line 101, in GetOpJson
File "/sys/TDModules/TDJSON", line 264, in opToJSONOp
File "/sys/TDModules/TDJSON", line 245, in pageToJSONDict
File "/sys/TDModules/TDJSON", line 185, in parameterToJSONPar
td.Error: Custom parameter expected. Value:type:Par name:extension1 owner:/TEST_MANAGER value: Type:<class 'td.Par'>.
Results of run operation resulted in exception.
Passing no extra attributes doesn’t cause any issue. Passing only a handful of attributes such as [‘val’, ‘owner’, ‘label’] will work fine. My guess is that either one or multiple of those extra attributes are not available (or protected) on builtin parameters.
So:
- Could we get the list of safe attributes for Built-in parameters ?
- Could we get the list of safe attributes for Custom parameters ?
- Would it be possible to add an argument such as
quietlyFail=True
where if an attribute that cannot be returned is provided, then it will just be skipped ?
Thank you for your time,
Michel