Convert between XML/JSON in Logic Apps workflows with the XML-JSON Converter
To run simple XML/JSON transformations, the built-in Logic Apps expressions json and xml do the job fine. When additional mapping, selection, or custom structures are required, the built-in expressions might be too complex to set up.
Invictus provides a XML/JSON Converter component which converts XML/JSON contents, while running a XSLT transformation beforehand (stored in Azure Blob Storage). Removing the complexity from the Logic App
Available endpoints
/api/XmlToJson: transforms incoming request with XML contents to a response with the JSON result./api/JsonToXml: transforms incoming request with JSON contents to a response with the XML result.
- XML ➡️ JSON
- JSON ➡️ XML
The /api/XmlToJson endpoint transforms a provided BASE 64-encoded XML contents to a BASE 64-encoded JSON result. A XSLT transformation (stored in the Azure Blob Storage container called xmltojsonconfigstore) gets run beforehand to map the request in the right structure. This stored transformation gets gets referenced in the request.
| Request property | Required | Description |
|---|---|---|
Content | yes | The BASE 64-encoded XML contents. |
ConfigName | yes | The file name of the XSLT transformation, stored in Azure Blob Storage. |
Context | no | The dictionary providing context to the conversion, gets copied 1:1 to the response. |
XPath | no | The XPath expression that selects a specific XML node before the XSLT transformation. |
JPath | no | The JPath expression that selects a specific JSON property after the XSLT transformation. |
Full request JSON body example
// POST /api/XmlToJson
{
"Content": "eyJFbnZlbG9wZSI6IHiU2FsZXNPcmRlckluIjp7ICAgICAgICAg...." ,
"ConfigName":"IDD038-inbound.xsl",
"XPath": "/CustomerAccount/Message",
"JPath": "$.Envelope",
"Context": {
"x-conversationId": "29500405-d7cf-4877-a72b-a3288cff9dc0"
}
}
Full response JSON body example
// 200 OK <- /api/XmlToJson
{
"Content": "ejHixZlwI9HiU2FsxNPcmRluIjp7ICAgICagICa...",
"Context": {
"x-conversationId": "29500405-d7cf-4877-a72b-a3288cff9dc0"
}
}
The /api/JsonToXml endpoint transforms a provided BASE 64-encoded JSON contents to a BASE 64-encoded XML result. A XSLT transformation (stored in the Azure Blob Storage container called xmltojsonconfigstore) gets run beforehand to map the request in the right structure. This stored transformation gets gets referenced in the request.
| Request property | Required | Description |
|---|---|---|
Content | yes | The BASE 64-encoded JSON contents. |
ConfigName | yes | The file name of the XSLT transformation, stored in Azure Blob Storage. |
Context | no | The dictionary providing context to the conversion, gets copied 1:1 to the response. |
JPath | no | The XPath expression that selects a specific JSON property before the XSLT transformation. |
XPath | no | The JPath expression that selects a specific XML node after the XSLT transformation. |
Full request JSON body example
// POST /api/JsonToXml
{
"Content": "eyJFbnZlbG9wZSI6IHiU2FsZXNPcmRlckluIjp7ICAgICAgICAg...." ,
"ConfigName":"IDD038-inbound.xsl",
"JPath": "$.Envelope",
"XPath": "/CustomerAccount/Message",
"Context": {
"x-conversationId": "29500405-d7cf-4877-a72b-a3288cff9dc0"
}
}
Full response JSON body example
// 200 OK <- /api/JsonToXml
{
"Content": "ejHixZlwI9HiU2FsxNPcmRluIjp7ICAgICagICa...",
"Context": {
"x-conversationId": "29500405-d7cf-4877-a72b-a3288cff9dc0"
}
}
Customization
Related Bicep parameters
The following Bicep parameters control the inner workings of the XML/JSON Converter component. See the release pipeline step of the deployment of the Invictus Framework to learn more.
| Bicep parameter | Default | Description |
|---|---|---|
storageAccountName | invictus{resourcePrefix}store | The name of the Azure Storage Account (used by other Framework components as well) where the xmltojsonconfigstore Azure Blob Storage container will be located. |
xmlJsonConverterScaling | { cpuResources: '0.5', memoryResources: '1.0Gi', scaleMaxReplicas: 1, scaleMinReplicas: 0, concurrentRequests: 10 } | The Container App options to control scaling. See scaling rules in Azure Container Apps. |
xmlJsonConverterFunctionName | inv-{resourcePrefix}-xmljsonconverter | The name of the Azure Container App to be created for the XML/JSON Converter component. |