Free MuleSoft CONNECT Keynote & Expo Pass Available!

Register now+
Nav

sizeOf

sizeOf(Array<Any>): Number

Returns the number of elements in an array (or anything that can be converted to an array, such as a string).

Transform

        
     
1
2
3
4
5
6
%dw 2.0
output application/json
---
{
  arraySize: sizeOf([1,2,3])
}
Output

        
     
1
2
3
{
  "arraySize": 3
}
sizeOf(Object): Number

Returns the number of elements in an object.

Transform

        
     
1
2
3
4
5
6
%dw 2.0
output application/json
---
{
  objectSize: sizeOf({a:1,b:2})
}
Output

        
     
1
2
3
{
  "objectSize": 2
}
sizeOf(Binary): Number

Returns the byte length of a binary value.

sizeOf(String): Number

Returns the number of characters in an string.

Transform

        
     
1
2
3
4
5
6
%dw 2.0
output application/json
---
{
  textSize: sizeOf("MuleSoft")
}
Output

        
     
1
2
3
{
  "textSize": 8
}