$$length
Returns the length of a value
Usage​
{
"$$length": /* Value to check length of (`string`/`object`/`array`) */,
"type": "AUTO" /* or STRING / ARRAY / OBJECT */,
"default_zero": false /* boolean */
}
"$$length([type],[default_zero]):{input}"
note
Concrete values in the usage example are default values.
Returns​
integer
Arguments​
Argument | Type | Values | Required / Default Value | Description |
---|---|---|---|---|
Primary | any | Yes | Value to check length of (string /object /array ) | |
type | enum | AUTO / STRING /ARRAY /OBJECT | AUTO | Restrict the type of value to check length of (if specified type no detected the result will be null ) |
default_zero | boolean | false /true | false | Whether to return 0 instead of null (on any kind of issue) |
Examples​
Input
Definition
Output
"Hello World"
"$$length:hello world"
11
"Hello World"
"$$length():$"
11
[
"Hello",
"World"
]
"$$length:$"
2
{
"a": "Hello",
"b": "World",
"c": "foo",
"d": "bar"
}
"$$length:$"
4
"Hello World"
"$$length(STRING):hello world"
11
"Hello World"
"$$length(STRING):$"
11
[
"Hello",
"World"
]
"$$length(STRING):$"
null
{
"a": "Hello",
"b": "World",
"c": "foo",
"d": "bar"
}
"$$length(STRING):$"
null
"Hello World"
"$$length(ARRAY):hello world"
null
"Hello World"
"$$length(ARRAY):$"
null
[
"Hello",
"World"
]
"$$length(ARRAY):$"
2
{
"a": "Hello",
"b": "World",
"c": "foo",
"d": "bar"
}
"$$length(ARRAY):$"
null
"Hello World"
"$$length(OBJECT):hello world"
null
"Hello World"
"$$length(OBJECT):$"
null
[
"Hello",
"World"
]
"$$length(OBJECT):$"
null
{
"a": "Hello",
"b": "World",
"c": "foo",
"d": "bar"
}
"$$length(OBJECT):$"
4
null
"$$length:$"
null
null
"$$length(AUTO,true):$"
0
42
"$$length(AUTO,true):$"
0
true
"$$length(AUTO,true):$"
0