Map Structured JSON Response Body
To map a simple and structured JSON response body, follow these steps:
- From the Response Body Content Type field, select JSON.
- In the mapping table, click the Add icon next to the mapping line.
- In Connector field name enter the name of the property you want to map from the JSON response body.
- Leave the Connector field type field empty.
- In the Druid entity field name, type [[, select the entity, then select the entity field where you want to store the property from the response.
- Click the Save icon next to the mapping line.
- Save the integration.
Example use cases
This section helps you understand how to map the response body based on the response entity, the complexity of the response body and the entity where you want to save the response body.
Map flat JSON object
In this example, the response entity is [[Contract]] and the response body is a flat JSON object:
Fields Mapping:
- Connector field name: ContractNumber → Druid entity field: [[Contract]].CNumber
- Connector field name: ContractValue → Druid entity field: [[Contract]].Value
Map nested JSON object
In this example, the response entity is [[Contract]] and the response body is a nested JSON object:
Fields Mapping:
- Connector field name: Contract.ContractNumber → Druid field: [[Contract]].CNumber
- Connector field name: Contract.ContractValue → Druid field: [[Contract]].Value
Use the dot notation (Parent.Child) in the Connector field name to access nested values.
Map a collection of objects to another Entity’s collection
In this example, the response entity is [[Employee]] and you want to save the list of contracts to an Entity List field like [[Employee]].Contracts.
The response body is a collection:
Response body is a collection
[
{
"ContractNumber": "DRUID-1234",
"ContractValue": 150.00
},
{
"ContractNumber": "DRUID-1235",
"ContractValue": 200.00
},
{
"ContractNumber": "DRUID-1236",
"ContractValue": 250.00
}
]
Response settings:
- Make sure Response Entity Is Collection is disabled at integration level, since [[Employee]].Contracts is already an entity list.
- In the Project Result to Entity Path field, select [[Employee]].Contracts.
Fields Mapping
In the mapping table, map the fields of the list’s entity type ([[Contract]] in this case), not the root entity ([[Employee]]):
- Connector field name: ContractNumber → Druid entity field: [[Contract]].CNumber
- Connector field name: ContractValue → Druid entity field: [[Contract]].Value
Map a collection of objects in the root entity
In this example, the response entity is [[Contract]].
Response settings:
- Make sure Response Entity Is Collection is enabled at integration level.
- Leave the Project Result to Entity Path field, empty.
Fields Mapping
In the mapping table, map the fields of the root entity ([[Contract]]):
- Connector field name: ContractNumber → Druid entity field: [[Contract]].CNumber
- Connector field name: ContractValue → Druid entity field: [[Contract]].Value