JSON Content Patterns
You can use the REST Adapter to implement the following common patterns with JSON content.
Map JSON when the REST Adapter Request is Configured with multipart/form-data
JSON can be mapped when the REST Adapter request is configured with multipart/form-data (that is, when the Request is multipart with payload and Multipart request is of type multipart/form-data with HTML form payload check boxes are selected on the Request page).
You can send a JSON string as a parameter. The name of the parameter is jsonInputParameters. The value of the parameter is the JSON string shown below. The value should be mapped to the parameter node. In general, ParameterList contains a list of parameters. Each parameter's name goes into parameter > name and its value goes into parameter.
JSON to XML Special Character Conversion
If the JSON payload has special characters that are not valid in XML, those characters are replaced by a string when converted from JSON to XML.
{
"_id": {
"$oid": "52cdef7f4bab8bd67529c6f7"
}
}
You then select the JSON Sample payload format and <<inline>> to copy and paste the payload into the text field in the Adapter Endpoint Configuration Wizard.
In the mapper, the field $oid
is represented with a string value of _0x646c72_oid
.
The list of special characters and their corresponding XML conversion strings are as follows:
Special Character | Converted Value Represented in the Mapper |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Send an Empty JSON Object
The REST Adapter can enforce the sending of an empty JSON object ({}
) when needed with
the Enforce Empty JSON Object Payload property. Some providers have
this requirement in special cases, such as Concur. When enabled, this property inserts an
empty JSON object.
When set to true, the REST call
inserts {}
into the body regardless of the verb chosen. For some
third party APIs, this is a requirement for certain calls. By default, this property
is not enabled.
The following steps provide a high level overview of how to configure an empty JSON object.
Copy Element Names as Values in JSON
You can copy element names as values in JSON.
JSON Sample | XSLT Mapping | Explanation |
---|---|---|
|
|
Iterate over child elements of a required element.
Capture the name and value as required. |
Use JSON Objects With Single Elements Within an Array
You can use JSON objects with single elements within an array.
JSON Sample | XSLT Mapping | Explanation |
---|---|---|
|
|
An array in JSON is a repeating element in XML.
An XML element is an item in a JSON object. |