ExtractVariables? JSONToXML? Not sure. having multiple nodes

Hi,

I am facing some issues in json to xml conversion. i am guessing most of us have encountered it .

Below is my JSON structure input

{
	"val": "X",
	"DataPoint": [{
			"code": "TK",
			"desc": "Tickets"
		},
		{
			"code": "PK",
			"desc": "Parking"
		}
	]
}

i am unable to extract above using extract variables - as number of nodes of "DataPoint" tag is dynamic.

How do i convert above json to xml objects of "DataPoint" ?.

Apigee is so cool when it comes to xml to json , but above scenario is very complex for me.

Can you help me please?

Note: i am having error when using tag "nodeset" (probably maybe as i am still using older version of on-premise edge)

Thanks & Best Regards

Sujith Mathew

Solved Solved
0 1 195
1 ACCEPTED SOLUTION

Which thing are you using? ExtractVariables or JSONToXML ?

There are two distinct policies.

How do i convert above json to xml objects of "DataPoint" ?.

I'm not sure what you mean by "objects". But using JSONToXML you can convert the above to:

<?xml version="1.0" encoding="UTF-8"?>
<Root>
  <val>X</val>
  <DataPoint>
    <code>TK</code>
    <desc>Tickets</desc>
  </DataPoint>
  <DataPoint>
    <code>PK</code>
    <desc>Parking</desc>
  </DataPoint>
</Root>

The JSONToXML policy configuration I used for this was:

<JSONToXML name='JSONToXML-1'>
  <Source>request</Source>
  <OutputVariable>transformed.content</OutputVariable>
  <Options/>
</JSONToXML>

View solution in original post

1 REPLY 1

Which thing are you using? ExtractVariables or JSONToXML ?

There are two distinct policies.

How do i convert above json to xml objects of "DataPoint" ?.

I'm not sure what you mean by "objects". But using JSONToXML you can convert the above to:

<?xml version="1.0" encoding="UTF-8"?>
<Root>
  <val>X</val>
  <DataPoint>
    <code>TK</code>
    <desc>Tickets</desc>
  </DataPoint>
  <DataPoint>
    <code>PK</code>
    <desc>Parking</desc>
  </DataPoint>
</Root>

The JSONToXML policy configuration I used for this was:

<JSONToXML name='JSONToXML-1'>
  <Source>request</Source>
  <OutputVariable>transformed.content</OutputVariable>
  <Options/>
</JSONToXML>