How to extract field values from a JSON message without using an XML schema in BusinessWorks and BusinessWorks Container Edition

Emmanuel Marchiset
4 min readJan 27, 2025

--

This is more and more common for data exchanges scenarios to be managed using the JSON data format while it is more compact and more flexible than XML.

It is usually needed to create XML schemas to handle JSON messages in BusinessWorks while this software relies on XML to manage data structures and transformations.

In some cases JSON messages to manage in BusinessWorks have many variants and new variants are introduced very often creating a situation where it is difficult to create and maintain XML schemas to handle such messages.

This article is to present a solution allowing to extract field values from an input JSON message in BusinessWorks without using an XML schema.

This can be done using the following steps:

#1 Parse the input JSON message to a generic XML string

This can be done using the following approach:
. Configure a Parse JSON activity with Schema Type = Generic
. Map the JSON string to process in the Input of the activity

Parse JSON activity with Generic Schema Type

This activity produces an XML string in a generic XML format matching the structure of the input JSON message and without any namespace.

#2 Parse the XML string to a generic XML schema

This can be done with the following approach:

. Create a generic XML schema able to handle any XML object
For this you can use the following schema:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="root"/>
</xs:schema>

. Configure a Parse XML activity with the ‘Validate Output’ option disabled and the XML schema previously created defined as Output Schema

Parse XML activity with the ‘Validate Output’ option disabled

This activity produces a generic XML object matching the structure of the input JSON message.

#3 Use the fields from the generic XML schema in mappings as needed

You can now use the generic XML schema in mappings using the field names from the received JSON message.

For example if there is an ‘OrdId’ field at the root level in the JSON string and the Parse Xml activity name is ‘ParseXml’ you can use the following path to access the value of the ‘OrdId’ field : $ParseXml/OrdId

Using fields from input JSON message in a mapping

It is possible to manage multiple levels and repeating parts in the JSON message.

Note that warnings are reported in the ‘Problems’ tab.

Additional elements

# Creation of an XSD schema from a JSON message payload

For JSON messages with a limited number of variants you can do the following to create an XML schema from a sample message:

. Right click on the Schemas folder
. Do New -> XML Schema File from JSON Payload

Creation of an XML schema from a JSON message

Using this tool this is sometimes needed to edit the created XML schema to handle variants of the JSON message.

You may also use third party XML tools to create XML schemas from JSON messages.

# Filtering extra fields in a JSON message

When using an XML schema in BusinessWorks it is still possible to filter extra fields from the JSON message using the approach explained in this other article:

# BusinessWorks 5.X

The approach described in this article can also be used with BusinessWorks 5.X

If you are using BusinessWorks 5.X the following article can also be useful:

--

--

Emmanuel Marchiset
Emmanuel Marchiset

Written by Emmanuel Marchiset

I work as an Architect at TIBCO Software on Integration products. Opinions here are my own.

No responses yet