Created
February 11, 2019 04:52
-
-
Save riebschlager/d910868acfa44507118e2bff3c2ca450 to your computer and use it in GitHub Desktop.
Working with JSON in TouchDesigner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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