HTTP & JSON
jsonArray
$jsonArray[]
$jsonArray converts a delimited string value into a JSON array by splitting on a separator. It is useful when data arrives as delimited text (CSV lines, tagged values) and must be handled as an array. It returns an empty string.
Syntax
bdfd
$jsonArray[(key);(...);(separator)]
Parameters
- With one argument, it is the path and the separator is
,. - With two or more arguments, the last one is the separator and the preceding ones are the path (one argument per level, no dot notation). The separator is used as written (a space or
,is kept); an empty separator keeps the whole string as a single element. - With no argument, the path is the whole document.
Behavior
- If the value at the path is a non-empty string, it is split on the separator.
- If the value is already an array, it is left unchanged.
- Otherwise (missing path, empty string, number, object…), the value is replaced by an empty array.
Examples
Split a string into an array
$jsonParse[{"tags":"discord,bot,bdfd"}]
$jsonArray[tags]
$title[JSON Array Elements]
$description[First tag: `$jsonValue[tags;0]`
Total tags: **$jsonArrayCount[tags]**]
$color[#00BCD4]
Custom separator
$jsonParse[{"tags":"discord bot bdfd"}]
$jsonArray[tags; ]
$sendMessage[$jsonStringify]
Try it
Paste an example into the playground to preview its message (functions that act on Discord are not run), or build the same thing with blocks.