Skip to content

Instantly share code, notes, and snippets.

@riebschlager
Created February 11, 2019 04:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save riebschlager/d910868acfa44507118e2bff3c2ca450 to your computer and use it in GitHub Desktop.
Save riebschlager/d910868acfa44507118e2bff3c2ca450 to your computer and use it in GitHub Desktop.
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