Skip to content

Instantly share code, notes, and snippets.

@atskimura
Created February 26, 2024 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atskimura/8bb4cabdfe2c966b755ddc89f3051457 to your computer and use it in GitHub Desktop.
Save atskimura/8bb4cabdfe2c966b755ddc89f3051457 to your computer and use it in GitHub Desktop.
%dw 2.0
input payload csv
output application/json
var category = (age: Number) -> if (age < 30) "young" else "adult"
---
payload map (row, rowIndex) -> {
name: row.name,
age: row.age as Number,
city: row.city,
category: category(row.age)
}
name age city
John 30 New York
Jane 25 Los Angeles
[
{
"name": "John",
"age": 30,
"city": "New York",
"category": "adult"
},
{
"name": "Jane",
"age": 25,
"city": "Los Angeles",
"category": "young"
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment