I was just going over the structure again, and it seems fine to me.
def transform(self, value, quality, timestamp):
itemDefs = system.util.jsonDecode(str(value))
defaultItem = {'target':'','items':[],'navIcon': {'path':''},'label': {'text':'','icon': {'path':''}},'showHeader': True}
items = []
for iDef in itemDefs:
if iDef['MenuVisible']:
thisItem = dict(**defaultItem)
thisItem['target'] = iDef['MenuTarget']
thisItem['label']['text'] = iDef['MenuLabel']
items.append(thisItem)
I thought that there might be a missing (or extra) set of curly braces that would cause the label:text
to be overwritten, but I don't see that.
FWIW, here is the returned data:
[{"showHeader":true,"navIcon":{"path":""},"label":{"icon":{"path":""},"text":"4"},"items":[],"target":"1"},
{"showHeader":true,"navIcon":{"path":""},"label":{"icon":{"path":""},"text":"4"},"items":[],"target":"2"},
{"showHeader":true,"navIcon":{"path":""},"label":{"icon":{"path":""},"text":"4"},"items":[],"target":"3"},
{"showHeader":true,"navIcon":{"path":""},"label":{"icon":{"path":""},"text":"4"},"items":[],"target":"4"}]
Where the text should be numbered the same as target.