Division/extraction of JSON nodes

Post Reply
schmitzdp
Member
Posts: 60
Joined: Thu Aug 06, 2020 1:36 pm

Division/extraction of JSON nodes

Post by schmitzdp »

Hello,

Is there an application or method that allows JSON or XML metadata from multiple nodes to be broken down into as many JSON or XML files as there are nodes?

Below is my example with two data sets that I would like to split into two separate files.
Image


(Sorry if this question has already been asked, I couldn't find it.)

Thanks
laurentd
Member
Posts: 157
Joined: Wed Mar 13, 2019 2:06 pm

Re: Division/extraction of JSON nodes

Post by laurentd »

You can use Variable XPath Repeater with XML datasets.
It will duplicate the job n times, and add the corresponding private data.

XML Repeater can split an XML file in several files.
Laurent De Wilde, Solution Architect @ Enfocus
User avatar
tdeschampsBluewest
Member
Posts: 147
Joined: Tue Jun 01, 2021 11:57 am

Re: Division/extraction of JSON nodes

Post by tdeschampsBluewest »

Hi,

You can achieve this with DatasetTools.
It also works with JSON and XML (even though the documentation doesn’t mention it yet, I need to update that!).

In your case, the access path to the recurring node will look like this:
lines/line


Exemple of input :

Code: Select all

{
    "customer":"John Doe",
    "email": "john@doe.com",
    "lines": {
        "line": [
            {
                "order": "A",
                "deliveryDate": "250101"
            },
            {
                "order": "B",
                "deliveryDate": "250102"
            },
            {
                "order": "C",
                "deliveryDate": "250103"
            },
            {
                "order": "D",
                "deliveryDate": "250104"
            }
        ]
    }
}

It will output in the "Log" outgoing connection 4 JSON, and the first one will look like this :

Code: Select all

{
	"customer": "John Doe", // requires "Keep top level structure" set to Yes
	"email": "john@doe.com",// requires "Keep top level structure" set to Yes
	"lines": {
		"line": {
			"order": "A", 
			"deliveryDate": "250101"
		}
	}
}
If you’d like more details, feel free to reach out at appstore@bluewest.fr or by MP, so we could share back a small flow tailored to your example.
Do you like the Enfocus Apps developed by Bluewest?
Feel free to leave a comment on the Appstore!
Post Reply