C3 Data Convert Example

4

Index

Stats

3,085 visits, 6,450 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

Array to JSON:as Flat Array

Another usage is to save it as an Array, which is helpful for searching, sorting, and filtering.

{
    "items": [
	    { "ID": "a001", "Name":"Apple", "Cost":12 },
	    { "ID": "a002", "Name":"Banana", "Cost":24 },
	    { "ID": "a003", "Name":"Carrot", "Cost":32 },
    ]
}

In this way, you can get item data through JSON.

JSON.Get("items.0.Name") // Apple

clipboard (need Object: Array, JSON)

{"is-c3-clipboard-data":true,"type":"events","items":[{"functionName":"ConvertArrayToJSONArray","functionDescription":"","functionCategory":"","functionReturnType":"none","functionCopyPicked":false,"functionIsAsync":false,"functionParameters":[],"eventType":"function-block","conditions":[],"actions":[{"id":"set-path","objectClass":"JSON","parameters":{"path":"\"items\""}},{"id":"set-array","objectClass":"JSON","parameters":{"path":"Self.Path","size":"0"}}],"children":[{"eventType":"block","conditions":[{"id":"repeat","objectClass":"System","parameters":{"count":"Array.Height-1"}}],"actions":[{"id":"push-value","objectClass":"JSON","parameters":{"where":"back","path":"\"items\"","value":"loopindex"}},{"id":"set-path","objectClass":"JSON","parameters":{"path":"\"items.\" & loopindex"}},{"id":"set-object","objectClass":"JSON","parameters":{"path":"Self.Path"}}],"children":[{"eventType":"block","conditions":[{"id":"for-each-element","objectClass":"Array","parameters":{"axes":"x"}}],"actions":[{"id":"set-value","objectClass":"JSON","parameters":{"path":"\".\" & str(Array.CurValue)","value":"Array.At(Array.CurX, 1+loopindex)"}}]}]}]}]}
  • 0 Comments

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