top of page
lp.jpeg

Blog

Tags:

How to move your code from the DataWeave Playground to Visual Studio Code



 

In this post:

 


If you’re not familiar with the online DataWeave Playground yet, this is an online tool that you can access from your browser to develop DataWeave code without having to open Anypoint Studio. It is mainly recommended for training purposes because of its limitations - since it’s running from your browser, it’s limited to the amount of memory allocated in your browser. There is a workaround to run it locally with the Docker image (see How to run locally the DataWeave Playground Docker Image) but this image might stop being supported in the future. That’s why it’s best to start using Visual Studio Code if you want to develop more complex code and need more performance for bigger payloads.


Here’s a video to complement your learnings from this article:




Advantages


Here are a few advantages of using the DataWeave extension for Visual Studio Code instead of the DataWeave Playground (there are more, but these seemed more important for now):

  • Handle bigger payloads

  • Get code suggestions

  • Create unit tests for your code

  • Create documentation for your code

  • Debug your scripts



Install the extension on VSCode


Before starting, make sure your extension on VSCode has been correctly installed. You can follow the next steps or see a detailed guide here: Getting started with the DataWeave extension for Visual Studio Code.

  1. Install Visual Studio Code.

  2. Install Java 8 and Maven version 3.6.3 or higher.

  3. Install the DataWeave extension for Visual Studio Code.


And that’s it!



Export the code from the Playground


We are assuming you already have some code going on in the DataWeave Playground. If this is not the case, you can simply open the Playground and use the sample code that is automatically generated.


1. From the DataWeave Playground, click on the Export button at the top.


2. This will download a .zip file to your computer.


3. Extract the contents of the .zip file. This root folder is the one you’ll refer to from VSCode. It contains a pom.xml file and a src folder.


4. Open VSCode and select File > Open Folder