Let's run through a quick example.
- Let's say that API Express service has two query parameter called: temperature (number) and units (string).
- Drag and drop the MAPPING component on to the service flow.
- In MAPPING component properties the first text area is where you define the response of this component. It can be any valid JSON response. In our example, enter the following:
This means that the MAPPING component output will be in that JSON format.
- Click on the Generate mapping button.
- Click the Expand all links on both sides of the mapping editor. On the left-hand side, you should see the two query parameters (Params > Query) and on the right-hand side, you should see the MAPPING component output that you just defined.
- Using drag and drop create the following mapping:
- temperature to currentTemperature
- units to temperatureUnit
- Click the Save & Replace button. This will generate the mapping code and display it in MAPPING component properties.
With the help of the MAPPING component, you created a component that outputs a custom JSON result.
var result = AE.EntityAPI("result", AE_MODEL); result.currentTemperature = PARAMS.QUERY.temperature + 5; result.temperatureUnit = PARAMS.QUERY.units;
When you write custom code, the visual mapping editor will not be updated.
Updated over 2 years ago