This is a simple example of how to reformat your input JSon to an Output JSon that is similar, but definitely different. For this use case, I have a JSon input that looks like this:
{
"color": "blue",
"weight": "10",
"packageType": "cardboard box",
"inventoryItemID": "123456789"
}
The output I want to generate from this looks like this:
{
"COLOR": "blue",
"WEIGHT": "10",
"INVENTORY-ITEM-ID": "123456789",
"PACKAGE-TYPE": "cardboard box"
}
As you can see, the output uses UPPER CASE for the property names, but the input uses camelCase. There are two ways to solve this mapping problem. The first is with SET_PROPERTY. This function allows you to generate a new Property, with it's value, to the output variable. We start with an empty JSon ("{}") and then operate on that as the foundation for the OutputVar. Here is a what the mapping rule looks like once we've repeated the SET_PROPERTY for each output property:
For the weight mapping, I also used the GET_PROPERTY to show that you can also use this syntax in case the dot notation reference is not available to you. So, in this case, you are using the SET_PROPERTY, and the first argument is the value you want to put in the output, and then we use a string value input for the second argument, which is the property name. I just typed in WEIGHT into the Value option on the input as a String type.
The Second option to perform this same mapping uses the RESOLVE_TEMPLATE() function. This function will resolve any variables referenced through the $variablename$ notation. It can be used for a String or JSon input, and will fill the actual value of the variable as a replacement for the output. Here is the input string that I used as the Value string input to start the mapping rule:
{
"COLOR": $inputJSON.color$,
"WEIGHT": $inputJSON.weight$,
"INVENTORY-ITEM-ID": $inputJSON.inventoryItemID$,
"PACKAGE-TYPE": $inputJSON.packageType$
}
As long as you have the full path to the property that you want, this can be a really efficient way to create the output that you want. The $inputJSON.color$ will be replaced by "blue" in my example.
First, I create a local variable of type String with the Template value that I want to use to create my output:
Here is what the RESOLVE_TEMPLATE mapping rule looks like:
You can use either of these, and it just depends on your preference.
Please comment if you have any questions or feedback.
Thanks!