BookatlasTwo-Day MuleSoft → Salesforce Bootcamp
1 / 18 · Module 3 — DataWeave 2.0 Crash Course · filtered: cheatsheet⊞ allnext →

3.8`$` shorthand

DataWeave lets you write:

payload map {
    customerId: $.id,
    companyName: $.name
}

Here:

$

means:

current item

and:

$$

typically means:

current index/key depending on context

So:

payload map {
    index: $$,
    id: $.id
}

might produce:

[
  {
    "index": 0,
    "id": "1"
  },
  {
    "index": 1,
    "id": "2"
  }
]

For interview coding, I prefer the explicit syntax initially:

payload map (customer) -> ...

It's easier to reason about.