Module 11 - Dataweave Flashcards

1
Q

Valid Lambda Expression type -> function

A

(user) -> {firstName, LastName, email}

User parameter becomes object:
{
 "firstName": "Joe",
"lastName":"Smith",
"email":"Joe@abc.com"
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Dataweave {} represents an object

A
user: {
  firstName: payload.fname,
  lastName: payload.lname,
  address:{
     street: payload.street,
     townPin: payload.city
  }
}
payload
{
   "fname": "Joe",
   "lname": "Smith",
   "street": "Main Street",
   "city": "Charlotte"
}

becomes:

{
 "firstName": "Joe",
 "lastName":"Smith",
  "address": {
    "street":  "Main Street",
    "city":  "Charlotte"
  }
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  • represents multiple selection
A

Input

Joe
Tim
George    junk

Dataweave
names: payload.users.*name

Output

Joe
Tim
George
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

@ represents attribute of XML

A

bob

Dataweave
userId: payload.user.@id;

Output:
234

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Map Operators

$ - Single item of map
$$ - 0 based index of current item

A

Input

9.99
53
398

Transform
priceList: payload.prices map (
  '\$\$': {
     dollars: $
  }
 )
Output:
{
  "priceList": {
    [
      {
         "0":{
             "dollars": 9.99
         }
      },
      {
         "1":{
             "dollars": 53
         }
      }
      {
         "2":{
             "dollars": 398
         }
      }
    ]
  } 
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Map Operators

$ - Single item of map
$$ - 0 based index of current item

A

Input

9.99
53
398

Transform
priceList: payload.prices map (
  '\$\$': {
     dollars: $
  }
 )
Output:
{
  "priceList": {
    [
      {
         "0":{
             "dollars": 9.99
         }
      },
      {
         "1":{
             "dollars": 53
         }
      }
      {
         "2":{
             "dollars": 398
         }
      }
    ]
  } 
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

XML Trick 1

Output must resolve to single root object

A
{
  fname: "John",
  lname: "Smith"
}
fails no root object

name: {
fname: “John”,
lname: “Smith”
}

works

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

XML Trick 1

Output must resolve to single root object

A
{
  fname: "John",
  lname: "Smith"
}
fails no root object

name: {
fname: “John”,
lname: “Smith”
}

works

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Note on * multiselector

A

An expression can have multiple * such as

payload.music.artists.artist.discography.albums

will all albums.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly