Hi,
I'm trying to iterate over an array of JSON objects, with the template node and mustache templates (because I need to parse it to XML eventually).
For some reason though the keys return empty, and that I don't get back an array.
This is my flow:
[{"id":"6719f4f2.86966c","type":"inject","z":"8223ec9c.e8765","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"ORDERID\":\"PO20000005\",\"NOTES\":null,\"CREATEDATE\":\"2020-04-21T00:00:00+03:00\",\"PORDERITEMS\":[{\"ORDERLINE\":66,\"EXPECTEDDATE\":null,\"SKU\":\"abc\",\"QTYORDERED\":10,\"MNFPARTNO\":null},{\"ORDERLINE\":67,\"EXPECTEDDATE\":null,\"SKU\":\"def\",\"QTYORDERED\":11,\"MNFPARTNO\":null}]}","payloadType":"json","x":400,"y":540,"wires":[["14abf52a.65d51b"]]},{"id":"14abf52a.65d51b","type":"template","z":"8223ec9c.e8765","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n \"DATA\": {\n \"CONSIGNEE\": [\n \"123\"\n ],\n \"ORDERID\": [\n \"{{{PORDERS.ORDERID}}}\"\n ],\n \"ORDERTYPE\": [\n \"PO\"\n ],\n \"REFERENCEORD\": [\n \"123\"\n ],\n \"SOURCECOMPANY\": [\n \"100\"\n ],\n \"COMPANYTYPE\": [\n \"123\"\n ],\n \"NOTES\": [\n \"{{{PORDERS.NOTES}}}\"\n ],\n \"CREATEDATE\": [\n \"{{{PORDERS.CREATEDATE}}}\"\n ],\n \"LINES\": {\n {{{PORDERS.#PORDERITEMS}}}\n \"LINE\": {\n \"ORDERLINE\": [\n \"{{{ORDERLINE}}}\"\n ],\n \"REFERENCEORDLINE\": [\n \"2\"\n ],\n \"EXPECTEDDATE\": [\n \"{{{EXPECTEDDATE}}}\"\n ],\n \"SKU\": [\n \"{{{SKU}}}\"\n ],\n \"INVENTORYSTATUS\": [\n \"HOLD-IQC\"\n ],\n \"QTYORDERED\": [\n \"{{{QTYORDERED}}}\"\n ],\n \"MNFVALID\": [\"\"],\n \"MNFPARTNO\": [\n \"{{{MNFPARTNO}}}\"\n ],\n \"HZRD\": [\"\"]\n }\n {{{/}}}\n }\n }\n}","output":"json","x":560,"y":540,"wires":[["eeb76c21.cfdba","a3cebab6.a58b78"]]},{"id":"eeb76c21.cfdba","type":"debug","z":"8223ec9c.e8765","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":870,"y":540,"wires":[]},{"id":"a3cebab6.a58b78","type":"xml","z":"8223ec9c.e8765","name":"","property":"payload","attr":"","chr":"","x":710,"y":500,"wires":[["eeb76c21.cfdba"]]}]
My goal is that LINES will be an array with two objects, each for the PORDERITEMS item.
I would like some help understanding how to fix it.
Thanks!