You are here:
Convert a List of Objects to a List of Values (Managed Package)
For the managed package runtime, you can convert a list of JSON objects (key-value pairs in braces) to a list of single values, regardless of the length of the list. The trick is to use a formula to remove the second level of the hierarchy.
This information is for Omnistudio for Managed Packages. For Omnistudio on standard runtime, see Omnistudio Help.
To download a data pack of this example for Omnistudio for Managed Packages, click here.
To create an Omnistudio Data Mapper Transform that converts a list of objects to a list of values:
- Go the Data Mapper Designer tab and click New. The Create dialog is displayed.
-
Specify a name for the Data Mapper and configure its settings as follows:
-
Interface Type — Transform
-
Input Type — JSON
-
Output Type — JSON
-
- Click Save. The Transforms tab of the Data Mapper Interface page is displayed.
-
Go to the Formulas tab. In the Formula field, enter
ObjectList:Property. In the Formula Result Path field, enterFormulaList. -
Go to the Transforms tab. Expand the Input JSON pane and paste the following JSON data into it:
{ "ObjectList": [ { "Property": "P9034" } ] } -
Expand the Expected JSON Output pane and paste the following JSON data into it:
{ "PropertyValueList": [ "P9034" ] } -
Click the + icon and add the following mapping:
-
Input JSON Path — FormulaList
-
Output JSON Path — PropertyValueList
Note that you only have to create a mapping between the top-level nodes.
-
-
Expand the Current JSON Output pane. Its contents should look like this:
{ "PropertyValueList": "Text" } -
Go to the Preview tab and paste the following JSON data into the Input pane:
{ "ObjectList": [ { "Property": "P9034" }, { "Property": "P6538" }, { "Property": "P1234" }, { "Property": "P5678" }, { "Property": "P2345" }, { "Property": "P7654" } ] } -
Click Execute. The Response should look like this:
{ "PropertyValueList": [ "P9034", "P6538", "P1234", "P5678", "P2345", "P7654" ] } - Add or subtract list items in the JSON data in the Input pane and click Execute again. Note that the output changes accordingly.
