C3 Data Convert Example

4

Index

Stats

2,706 visits, 5,748 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 27 Dec, 2023. Last updated 11 Sep, 2024

target:

[
    { "id": 0, "name": "" },
    { "id": 1, "name": "" }
]
{"is-c3-clipboard-data":true,"type":"events","items":[{"eventType":"block","conditions":[{"id":"on-start-of-layout","objectClass":"System"}],"actions":[{"id":"parse","objectClass":"JSON","parameters":{"data":"\"[]\""}},{"id":"set-array","objectClass":"JSON","parameters":{"path":"\".\"","size":"0"}}],"children":[{"eventType":"block","conditions":[{"id":"repeat","objectClass":"System","parameters":{"count":"2"}}],"actions":[{"id":"push-value","objectClass":"JSON","parameters":{"where":"back","path":"\".\"","value":"0"}},{"id":"set-object","objectClass":"JSON","parameters":{"path":"\".\" & loopindex"}},{"id":"set-value","objectClass":"JSON","parameters":{"path":"StringSub(\".{0}.id\", loopindex)","value":"0"}},{"id":"set-value","objectClass":"JSON","parameters":{"path":"StringSub(\".{0}.name\", loopindex)","value":"\"\""}}]}]}]}

Or Use Javascript:

const dataInst = runtime.objects.JSON.getFirstInstance();

const data = [
	{ "id": 1, "name": ""},
	{ "id": 2, "name": ""},
]

dataInst.setJsonDataCopy(data);
  • 0 Comments

Want to leave a comment? Login or Register an account!