Hi Zeik
I am doing this in different places - either in communication scripts or in envelope. But the process is the same:
1. check the grammar and get the element name of the root element
2. read the data and use only the subset of the named element
Something along the line of:
from bots import grammar
def main(channeldict, filename, ta):
# Get Grammar to remove the 'root' element when sending.
ta.synall()
botsgrammar = grammar.grammarread(ta.editype, ta.messagetype, 'grammars')
rootid = botsgrammar.structure[0][0]
# Open the file and read json to dict. Later on, dict is sent back to JSON without root.
infile = open(filename)
data = json.loads(infile.read())
data = data[rootid]