DataWeave 2.x Playground coming to a container near you
Revealed at MuleSoft Connect 2020
Key take away’s
- Learn to program in DataWeave 2.x with minimal resistance
- Complete Read-Eval-Print-Loop (REPL) environment
- Go from concepts to solutions at lightening speed
For some time now we’ve been enjoying the benefits of REPL environments provided by languages such as JSFiddle, Go Playground and Katacoda. Yet, we’ve been wondering when we might have something similar for DataWeave?
At the May 2020 MuleSoft Connect we got a glimpse of what may be on the horizon. In the Deep Dive Tips and Tricks presentation with Jason Johl, we learned about an early evaluation Docker release of a DataWeave Playground container where we can prototype and experiment with DW 2.x solutions. While still a little rough around the edges, it lightweight, easy to use, feature rich and hopefully on a trajectory to long term maturity.
Kicking tires on dw-playground
# install and run dw-playground container$ docker run -it --rm -p9000:8080 machaval/dw-playground:2.3.1-SNAPSHOT
After the Docker image has downloaded and started up, point your browser to localhost port 9000, the playground DataWeave container.
XML Input Payload
<data>
<number>1</number>
<number>2</number>
<number>42</number>
<name>Foo Baz</name>
</data>
The DataWeave Playground allows you to define your inbound payloads which may be JSON, XML, CSV, TEXT, YAML and serveral other types. In the example above I created a transformation rule to extract all the data.number values in the input payload and render the output as a JSON array. The output transformation types are as rich and varied as the input types.
The other nice feature you can see in the lower panel, is the integration of DataWeave API guides and a log viewer.
Here are some additional DataWeave examples for you to play with in the playground:
DataWeave mapping from CSV to JSON
Input CSV Payload (extra whitespace is ignored)
id,varietal,color,body
1,Cabernet,Red,Full
2, Riesling,White,Light
3, Merlot, Red,Medium
DataWeave mapping from JSON to XML
Input JSON Payload
[
{
"id": "1",
"varietal": "Cabernet",
"color": "White",
"body": "Full"
},
{
"id": "2",
"varietal": " Riesling",
"color": "White",
"body": "Light"
},
{
"id": "3",
"varietal": " Merlot",
"color": "White",
"body": "Medium"
}
]
That should be enough to help you get started with the DataWeave Playground, it’s a great tool which is easy to use and should help boost your productivity with MuleSoft.