Hi everyone,
I have XML data as shown below:
<AccNum DT="alphabetnumericspecialspaces" IND="125" LSP="2" MNL="1" MXL="19" PL="" PRE="optional" RLI="3">000405010255</AccNum> <AccNum DT="alphabetnumericspecialspaces" IND="125" LSP="2" MNL="1" MXL="19" PL="" PRE="optional" RLI="3">000405010310</AccNum> <AccNum DT="alphabetnumericspecialspaces" IND="125" LSP="2" MNL="1" MXL="19" PL="" PRE="optional" RLI="3">000405009777</AccNum> <AccNum DT="alphabetnumericspecialspaces" IND="125" LSP="2" MNL="1" MXL="19" PL="" PRE="optional" RLI="3">000401109537</AccNum> <AccNum DT="alphabetnumericspecialspaces" IND="125" LSP="2" MNL="1" MXL="19" PL="" PRE="optional" RLI="3">000401113460</AccNum> <AccNum DT="alphabetnumericspecialspaces" IND="125" LSP="2" MNL="1" MXL="19" PL="" PRE="optional" RLI="3">000401116861</AccNum> <AccNum DT="alphabetnumericspecialspaces" IND="125" LSP="2" MNL="1" MXL="19" PL="" PRE="optional" RLI="3">001805015288</AccNum> <AccNum DT="alphabetnumericspecialspaces" IND="125" LSP="2" MNL="1" MXL="19" PL="" PRE="optional" RLI="3">628801537715</AccNum> <AccNum DT="alphabetnumericspecialspaces" IND="125" LSP="2" MNL="1" MXL="19" PL="" PRE="optional" RLI="3">000319000184</AccNum> <AccNum DT="alphabetnumericspecialspaces" IND="125" LSP="2" MNL="1" MXL="19" PL="" PRE="optional" RLI="3">000401193586</AccNum> <AccNum DT="alphabetnumericspecialspaces" IND="125" LSP="2" MNL="1" MXL="19" PL="" PRE="optional" RLI="3">000405111139</AccNum> <AccNum DT="alphabetnumericspecialspaces" IND="125" LSP="2" MNL="1" MXL="19" PL="" PRE="optional" RLI="3">000405501186</AccNum> <AccNum DT="alphabetnumericspecialspaces" IND="125" LSP="2" MNL="1" MXL="19" PL="" PRE="optional" RLI="3">000760004994</AccNum> <AccNum DT="alphabetnumericspecialspaces" IND="125" LSP="2" MNL="1" MXL="19" PL="" PRE="optional" RLI="3">000805015689</AccNum> <AccNum DT="alphabetnumericspecialspaces" IND="125" LSP="2" MNL="1" MXL="19" PL="" PRE="optional" RLI="3">000813001320</AccNum> <AccNum DT="alphabetnumericspecialspaces" IND="125" LSP="2" MNL="1" MXL="19" PL="" PRE="optional" RLI="3">001105024982</AccNum> <AccNum DT="alphabetnumericspecialspaces" IND="125" LSP="2" MNL="1" MXL="19" PL="" PRE="optional" RLI="3">001801080623</AccNum> <AccNum DT="alphabetnumericspecialspaces" IND="125" LSP="2" MNL="1" MXL="19" PL="" PRE="optional" RLI="3">001810042371</AccNum> <AccNum DT="alphabetnumericspecialspaces" IND="125" LSP="2" MNL="1" MXL="19" PL="" PRE="optional" RLI="3">001825075268</AccNum> <AccNum DT="alphabetnumericspecialspaces" IND="125" LSP="2" MNL="1" MXL="19" PL="" PRE="optional" RLI="3">004214109637</AccNum> <AccNum DT="alphabetnumericspecialspaces" IND="125" LSP="2" MNL="1" MXL="19" PL="" PRE="optional" RLI="3">004214109638</AccNum> <AccNum DT="alphabetnumericspecialspaces" IND="125" LSP="2" MNL="1" MXL="19" PL="" PRE="optional" RLI="3">010310000278</AccNum> <AccNum DT="alphabetnumericspecialspaces" IND="125" LSP="2" MNL="1" MXL="19" PL="" PRE="optional" RLI="3">032501004151</AccNum> <AccNum DT="alphabetnumericspecialspaces" IND="125" LSP="2" MNL="1" MXL="19" PL="" PRE="optional" RLI="3">044205008102</AccNum> <AccNum DT="alphabetnumericspecialspaces" IND="125" LSP="2" MNL="1" MXL="19" PL="" PRE="optional" RLI="3">105701000275</AccNum> <AccNum DT="alphabetnumericspecialspaces" IND="125" LSP="2" MNL="1" MXL="19" PL="" PRE="optional" RLI="3">630010075140</AccNum>
and i want to convert the above data in json format as shown below:
{ "AccNum": [ 405010255, 405010310, 405009777, 401109537, 401113460, 401116861, 1805015288, 628801537715, 319000184, 401193586, 405111139, 405501186, 760004994, 805015689, 813001320, 1105024982, 1801080623, 1810042371, 1825075268, 4214109637, 4214109638, 10310000278, 32501004151, 44205008102, 105701000275, 630010075140 ] }
how to convert this data in json format.
Solved! Go to Solution.
I would suggest converting to json using XML to json policy. Once this is in json, you can use a javascript policy to extract data and put into a json array.
"Invalid source type" could mean
Try this for a working example:
Did u try XMLtoJSON policy ? There is a sample example you can refer. You can achieve above scenario with minimal effort by using XSLT policy and XMLtoJSON.
I fetched the AccNum using Extract Variable and after that i used XMLtoJSON policy for convert the data but I'm getting Invalid source type. i checked the source type also but still getting same response.
Could you please post the extract variable policy code here. I will examine and suggest the changes.
The above XML doesnt have a root element, could you please check that as well.
I would suggest converting to json using XML to json policy. Once this is in json, you can use a javascript policy to extract data and put into a json array.
"Invalid source type" could mean
Try this for a working example:
Doesn't appear to be valid XML, there should be a single root element containing this data. I wouldn't expect any out of the box policies to work if it's not valid XML.
User | Count |
---|---|
3 | |
2 | |
1 | |
1 | |
1 |