I want to rewrite the data in the template, but it all becomes [object Object]

Image from Gyazo

I want to rewrite the data in the template as shown in the image, but it all becomes [object Object]. Is there a way to rewrite the contents of the data?

It would help if you show what is in payload.values.

Thank you very much. The contents are as stated below.

[
{
"Species": "Adelie",
"Island": "Torgersen",
"Beak Length (mm)": 39.5,
"Beak Depth (mm)": 17.4,
"Flipper Length (mm)": 186,
"Body Mass (g)": 3800,
"Sex": "FEMALE"
},
{
"Species": "Adelie",
"Island": "Torgersen",
"Beak Length (mm)": 39.5,
"Beak Depth (mm)": 17.4,
"Flipper Length (mm)": 186,
"Body Mass (g)": 3800,
"Sex": "FEMALE"
}
]

Below is a simplified flow

[{"id":"2f182f36.5de67","type":"template","z":"2eb2befc.213bf2","name":"","field":"payload","fieldType":"msg","format":"json","syntax":"mustache","template":"{\n  \"$schema\": \"https://vega.github.io/schema/vega-lite/v5.json\",\n  \"description\": \"A vertical box plot showing median, min, and max body mass of penguins.\",\n    \"width\": 500,\n  \"height\": 500,\n    \"padding\": 35,\n    \"config\": {\n    \"axis\": {\n\n      \"labelColor\": \"#333333\",\n     \"gridWidth\":1\n    }\n  },\n  \"data\":{\"values\":\"{{payload}}\"},\n   \"mark\": {\"type\": \"boxplot\", \"size\": 34,\"extent\": 1.5,\n    \"median\": {\"color\": \"red\"},\n    \"ticks\": true},\n  \"encoding\": {\n    \"x\": {\"field\": \"Species\", \"type\": \"nominal\"},\n    \"color\": {\"field\": \"Species\", \"type\": \"nominal\", \"legend\": null},\n    \"y\": {\n      \"field\": \"Body Mass (g)\",\n      \"type\": \"quantitative\",\n      \"scale\": {\"zero\": false}\n    }\n  }\n}","output":"json","x":340,"y":100,"wires":[["f17281c5.4eee5"]]},{"id":"f17281c5.4eee5","type":"debug","z":"2eb2befc.213bf2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":550,"y":60,"wires":[]},{"id":"3f261860.afae28","type":"inject","z":"2eb2befc.213bf2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"Bod\":3800},{\"Bod\":3800}]","payloadType":"json","x":150,"y":100,"wires":[["750d1328.7b62ac","2f182f36.5de67"]]},{"id":"750d1328.7b62ac","type":"debug","z":"2eb2befc.213bf2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload[0]","targetType":"msg","statusVal":"","statusType":"auto","x":330,"y":60,"wires":[]}]

JSON.stringify(...) ?

Or JSONata in a change node to create a string of the object, no quotes required.
e.g.

[{"id":"3f261860.afae28","type":"inject","z":"da8a6ef0b3c9a5c8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"Bod\":3800},{\"Bod\":3800}]","payloadType":"json","x":150,"y":2200,"wires":[["04d423388a8e526e"]]},{"id":"04d423388a8e526e","type":"change","z":"da8a6ef0b3c9a5c8","name":"","rules":[{"t":"set","p":"payload[0]","pt":"msg","to":"$string($$.payload[0])","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":2260,"wires":[["2f182f36.5de67","750d1328.7b62ac"]]},{"id":"2f182f36.5de67","type":"template","z":"da8a6ef0b3c9a5c8","name":"","field":"payload","fieldType":"msg","format":"json","syntax":"mustache","template":"{\n  \"$schema\": \"https://vega.github.io/schema/vega-lite/v5.json\",\n  \"description\": \"A vertical box plot showing median, min, and max body mass of penguins.\",\n    \"width\": 500,\n  \"height\": 500,\n    \"padding\": 35,\n    \"config\": {\n    \"axis\": {\n\n      \"labelColor\": \"#333333\",\n     \"gridWidth\":1\n    }\n  },\n  \"data\":{\"values\":{{{payload.0}}} },\n   \"mark\": {\"type\": \"boxplot\", \"size\": 34,\"extent\": 1.5,\n    \"median\": {\"color\": \"red\"},\n    \"ticks\": true},\n  \"encoding\": {\n    \"x\": {\"field\": \"Species\", \"type\": \"nominal\"},\n    \"color\": {\"field\": \"Species\", \"type\": \"nominal\", \"legend\": null},\n    \"y\": {\n      \"field\": \"Body Mass (g)\",\n      \"type\": \"quantitative\",\n      \"scale\": {\"zero\": false}\n    }\n  }\n}","output":"json","x":500,"y":2260,"wires":[["f17281c5.4eee5"]]},{"id":"750d1328.7b62ac","type":"debug","z":"da8a6ef0b3c9a5c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload[0]","targetType":"msg","statusVal":"","statusType":"auto","x":330,"y":2160,"wires":[]},{"id":"f17281c5.4eee5","type":"debug","z":"da8a6ef0b3c9a5c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":650,"y":2260,"wires":[]}]

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.