Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Working with JSON in TouchDesigner
# me - this DAT.
#
# dat - the changed DAT
# rows - a list of row indices
# cols - a list of column indices
# cells - the list of cells that have changed content
# prev - the list of previous string contents of the changed cells
#
# Make sure the corresponding toggle is enabled in the DAT Execute DAT.
#
# If rows or columns are deleted, sizeChange will be called instead of row/col/cellChange.
TDJ = op.TDModules.mod.TDJSON
tbl = op('table1')
def onTableChange(dat):
json = TDJ.textToJSON(dat.text)
if json is not None:
keys = list(json[0].keys())
tbl.clear()
tbl.appendRow(keys)
for item in json:
row = []
for key in keys:
row.append(item[key])
tbl.appendRow(row)
return
def onRowChange(dat, rows):
return
def onColChange(dat, cols):
return
def onCellChange(dat, cells, prev):
return
def onSizeChange(dat):
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.