{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Welcome to the DataWeave Jupyter Notebook\n", "\n", "## How to use it\n", "\n", "Enter any DataWeave script and the result will be shown.\n", "\n", "### Example:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "application/dw": "[\n 2, \n 4, \n 6\n]", "text/plain": [ "[\n", " 2, \n", " 4, \n", " 6\n", "]" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "[1,2,3,4,5,6] filter isEven($)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Storing Variables\n", "Use the `%var <variable name>` magic in order to store a value.\n", "\n", "### Example:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "application/dw": "[\n 1, \n 2, \n 3, \n 4, \n 5\n]", "text/plain": [ "[\n", " 1, \n", " 2, \n", " 3, \n", " 4, \n", " 5\n", "]" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%var payload\n", "[1,2,3,4,5]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "and that value van be reused later calling the `payload` value:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "application/dw": "[\n 1, \n 2, \n 3, \n 4, \n 5\n]", "text/plain": [ "[\n", " 1, \n", " 2, \n", " 3, \n", " 4, \n", " 5\n", "]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "payload" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Adding static imputs\n", "In order to add inputs to the execution context use the `%%input <input name> <content type>` magic cell. Example:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": {}, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%%input users application/json\n", "[{ \"name\" : \"Ana\"} , { \"name\" : \"Mariano\"}]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And use it later:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "application/dw": "[\n {\n name: \"Ana\"\n }, \n {\n name: \"Mariano\"\n }\n]", "text/plain": [ "[\n", " {\n", " name: \"Ana\"\n", " }, \n", " {\n", " name: \"Mariano\"\n", " }\n", "]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "users" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Render to Markdown\n", "When working with List of Objects you can use the `%mrkdwn` magic line in order to render tables to Markdown. Example:" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "|name|\n", "|--|\n", "|Ana|\n", "|Mariano|" ], "text/plain": [ "|name|\n", "|--|\n", "|Ana|\n", "|Mariano|" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%mrkdwn\n", "users" ] } ], "metadata": { "interpreter": { "hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49" }, "kernelspec": { "display_name": "DataWeave", "language": "dw", "name": "dataweave" }, "language_info": { "codemirror_mode": "dataweave", "file_extension": "dw", "mimetype": "application/dw", "name": "DataWeave", "nbconvert_exporter": "dataweave", "pygments_lexer": "dataweave", "version": "2.4" } }, "nbformat": 4, "nbformat_minor": 4 }