Dataweave vs Liquid Syntax

Ben Butler
2 min readSep 17, 2024

Here I am going to contrast the syntax of Dataweave.

  • Dataweave is a language for the transforming data
  • Liquid, in contrast, is a language used for templates.

The outcome of both are similar. They both output data in a way for consumption and, in that context, can be used for similar transformation purposes.

Example 1

//before
{
"fname": "John",
"lname": "Doe"
}

//after
{
"firstName": "John",
"lastName": "Doe"
}

Dataweave

{
firstName: input.fname,
lastName: input.lname
}

Liquid

{
"firstName": "{{ fname }}",
"lastName": "{{ lname }}"
}

Example 2

//before
{
"user": {
"name": "Alice",
"address": {
"city": "Wonderland",
"zip": "12345"
}
}
}

//after
{
"name": "Alice",
"city": "Wonderland",
"zip": "12345"
}

Dataweave

{
name: input.user.name,
city: input.user.address.city,
zip: input.user.address.zip
}

Liquid

{
"name": "{{ user.name }}",
"city": "{{ user.address.city }}",
"zip": "{{ user.address.zip }}"
}

Example 3

//before
{
"id": "123",
"active": "true"
}

//after
{
"id": 123,
"active": true
}

Dataweave

{
id: input.id as…

--

--