vincentlowe

addAndConcat (DWL)

Mar 31st, 2022
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. %dw 2.0
  2. output application/json
  3.  
  4. var a1 = [2,3,5,7,11]
  5. var r1 = 2 to 11
  6. var o1 = {one:1,two:2,three:3}
  7.  
  8. ---
  9. {
  10. // digits: a1,
  11. elements: o1,
  12. // moreDigits: a1 + r1, // r1 added as final element of result
  13. // flatDigits: a1 ++ r1, // elements from r1 appended to a1
  14. // arrayAndObject: a1 + o1, // o1 becomes final element of result
  15. // objectAndArray: o1 + a1, // error, you can't do that
  16. // objectWithNewArray: o1 ++ {stuff:a1},
  17. // alsoWithNewArray: o1 ++ stuff2: a1, // same as last line
  18. // concatObjects: o1 ++ o1 ++ {three:3,four:4},
  19. // filterObjects: o1 ++ o1 - "two", // subtraction before concatenation
  20. // sequencedFilter: (o1 ++ o1) - "two",
  21. // appendToArray: a1 << 100, // new append operator
  22. // prependToArray: 100 >> a1, // can you say push?
  23. // bigAppend: a1 << r1, // acts like the addition operator
  24. subtractElements: o1 - "two", // removes element with this key
  25. removeElement: o1 -- {two:2,one:1,three:7}, // removes all kvps that exist
  26. maskElements: o1 -- ["three","one"], // removes all elements with these keys
  27. removeByReference: o1 ++ o1 - "two",
  28. alsoRemove: (o1 ++ o1) - "two", // gets 'em all
  29. }
Advertisement
Add Comment
Please, Sign In to add comment