Skip to content

length

Description

Returns the number of characters in a string.

Syntax

Like many functions in DataPrime, length supports two notations, function and method notation. These interchangeable forms allow flexibility in how you structure expressions.

length(value: string): number
(value: string).length(): number

Arguments

NameTypeRequiredDescription
valuestringtrueThe string to measure

Example

Count the number of characters in a string

Consider the following document:

{
    "str_val": "such logs, much tracing, wow!"
}

Use length to count the number of characters:

create str_val_len from length(str_val)
create str_val_len from str_val.length()

Output

{
    "str_val": "such logs, much tracing, wow!",
    "str_val_len": 29
}