Free MuleSoft CONNECT Keynote & Expo Pass Available!

Register now+
Nav

++

++(Array<S>, Array<T>): Array<S | T>

Concatenates the elements of two arrays into a new array.

If the two arrays contain different types of elements, the resulting array is all of S type elements of Array<S> followed by all the T type elements of Array<T>. Either of the arrays can also have mixed-type elements.

The example concatenates an Array<Number> with an Array<String>.

Transform

        
     
1
2
3
4
5
6
%dw 2.0
output application/json
---
{
  result: [0, 1, 2] ++ ["a", "b", "c"]
}
Output

        
     
1
2
3
{
  "result": [0, 1, 2, "a", "b", "c"]
}

Note that the arrays can contain any supported data type, for example:

Transform

        
     
1
2
3
4
5
6
%dw 2.0
output application/json
---
{
  a: [0, 1, true, "my string"] ++ [2, [3,4,5], {"a": 6}]
}
Output

        
     
1
2
3
{
  "a": [0, 1, true, "my string", 2, [3, 4, 5], { "a": 6}]
}
++(String, String): String

Concatenates the characters of two strings.

Strings are treated as arrays of characters, so the ++ operator concatenates the characters of each String as if they were arrays of single character String. In the example, the String 'Mule' is treated as Array<String> ['M', 'u', 'l', 'e'].

Transform

        
     
1
2
3
4
5
6
%dw 2.0
output application/json
---
{
  name: 'Mule' ++ 'Soft'
}
Output

        
     
1
2
3
{
  'name': MuleSoft
}
++(Object, Object): Object

Concatenates two input objects and returns one flattened object.

The ++ operator extracts all the key-values pairs from each object, then combines them together into one result object.

Transform

        
     
1
2
3
4
%dw 2.0
output application/xml
---
concat: {aa: 'a', bb: 'b'} ++ {cc: 'c'}
Output

        
     
1
2
3
4
5
6
<?xml version='1.0' encoding='UTF-8'?>
<concat>
  <aa>a</aa>
  <bb>b</bb>
  <cc>c</cc>
</concat>

If you leave the output as application/dw, the example above concatenates each key-value pair from the two objects {aa: 'a', bb: 'b'} ++ {cc: 'c'} and returns a single object {aa: 'a' , bb: 'b', cc: 'c'}.

++(Date, LocalTime): LocalDateTime

Appends a LocalTime with a Date object and returns a more precise LocalDateTime value.

Date and LocalTime instances are written in standard Java notation, surrounded by pipe (|) symbols. The result is a LocalDateTime object in the standard Java format.

Transform

        
     
1
2
3
4
5
6
7
%dw 2.0
output application/json
---
{
  a: |2003-10-01| ++ |23:57:59|,
  b: |2003-10-01| ++ |23:57:59Z|
}
Output

        
     
1
2
3
4
{
    'a': '2003-10-01T23:57:59',
    'b': '2003-10-01T23:57:59Z'
}

Note that the order in which the two objects are concatenated is irrelevant, so logically, Date + LocalTime produces the same result as LocalTime + Date.

++(LocalTime, Date): LocalDateTime

Appends a LocalTime with a Date object and returns a more precise LocalDateTime value.

Transform

        
     
1
2
3
4
5
6
7
%dw 2.0
output application/json
---
{
  a: |23:57:59| ++ |2003-10-01|,
  b: |23:57:59Z| ++ |2003-10-01|
}
Output

        
     
1
2
3
4
{
    'a': '2003-10-01T23:57:59',
    'b': '2003-10-01T23:57:59Z'
}

Note that the order in which the two objects are concatenated is irrelevant, so logically, LocalTime + Date produces the same result as Date + LocalTime.

++(Date, Time): DateTime

Appends a Date to a Time object and returns a more precise DateTime value.

Transform

        
     
1
2
3
4
5
6
7
%dw 2.0
output application/json
---
{
  a: |2003-10-01| ++ |23:57:59|,
  b: |2003-10-01| ++ |23:57:59Z|
}
Output

        
     
1
2
3
4
{
    'a': '2003-10-01T23:57:59',
    'b': '2003-10-01T23:57:59Z'
}

Note that the order in which the two objects are concatenated is irrelevant, so logically, Date + Time produces the same result as Time + Date.

++(Time, Date): DateTime

Appends a Date to a Time object to return a more precise DateTime value.

Transform

        
     
1
2
3
4
5
6
7
%dw 2.0
output application/json
---
{
  a: |23:57:59| ++ |2003-10-01|,
  b: |23:57:59Z| ++ |2003-10-01|
}
Output

        
     
1
2
3
4
{
    'a': '2003-10-01T23:57:59',
    'b': '2003-10-01T23:57:59Z'
}

Note that the order in which the two objects are concatenated is irrelevant, so logically, Date + Time produces the same result as a Time + Date.

++(Date, TimeZone): DateTime

Appends a TimeZone to a Date type value and returns a DateTime result.

Transform

        
     
1
2
3
4
%dw 2.0
output application/json
---
a: |2003-10-01T23:57:59| ++ |-03:00|
Output

        
     
1
2
3
{
  'a': '2003-10-01T23:57:59-03:00'
}
++(TimeZone, Date): DateTime

Appends a Date to a TimeZone type value and returns a DateTime result.

Transform

        
     
1
2
3
4
%dw 2.0
output application/json
---
a: |-03:00| ++ |2003-10-01T23:57:59|
Output

        
     
1
2
3
{
  'a': '2003-10-01T23:57:59-03:00'
}
++(LocalDateTime, TimeZone): DateTime

Appends a TimeZone to a LocalDateTime type value and returns a DateTime result.

Transform

        
     
1
2
3
4
%dw 2.0
output application/json
---
a: |2003-10-01T23:57:59| ++ |-03:00|
Output

        
     
1
2
3
{
  'a': '2003-10-01T23:57:59-03:00'
}
++(TimeZone, LocalDateTime): DateTime

Appends a LocalDateTime to a TimeZone type value and returns a DateTime result.

Transform

        
     
1
2
3
4
%dw 2.0
output application/json
---
a: |-03:00| ++ |2003-10-01T23:57:59|
Output

        
     
1
2
3
{
  'a': '2003-10-01T23:57:59-03:00'
}
++(LocalTime, TimeZone): Time

Appends a TimeZone to a LocalTime type value and returns a Time result.

Transform

        
     
1
2
3
4
%dw 2.0
output application/json
---
a: |2003-10-01T23:57:59| ++ |-03:00|
Output

        
     
1
2
3
{
  'a': '2003-10-01T23:57:59-03:00'
}
++(TimeZone, LocalTime): Time

Appends a LocalTime to a TimeZone type value and returns a Time result.

Transform

        
     
1
2
3
4
%dw 2.0
output application/json
---
a: |-03:00| ++ |2003-10-01T23:57:59|
Output

        
     
1
2
3
{
  'a': '2003-10-01T23:57:59-03:00'
}