Skip to Content
avatar image
Former Member

Not able to transform JSON document to XML

Hi Experts,

While trying to transform JSON document to XML format, receiving following error in HCI flow:

"cannot transform JSON document to XML: JSON document contains either more than one member in the root object or an array with more than one value in the root object. Only one member in the root object with no array or array with one value is supported"

It seems that this is due to limitation of JSON to XML conversion in HCI.

Tried to add Groovy script as per this Question but no luck with solution.

Input data sample is as below:

{"kind":"analytics#Data","id":"https://www.....com/v3/data? ids=xxx∈put1=value1,value2,value3,value4,value5,value6∈put2=Value7☆t-date=2daysAgo&end-date=1daysAgo&max-results=10","query":{"start-date":"2daysAgo","end-date":"1daysAgo","ids":"xxx","input1":"value1,value2,value3,value4,value5,value6","input2":["Value7"],"start-index":1,"max-results":10},"itemsPerPage":10,"totalResults":8568,"selfLink":"https://www......com/v3/data?ids=xxx∈put1=value1,value2,value3,value4,value5,value6∈put2=Value7☆t-date=2daysAgo&end-date=1daysAgo&max-results=10","nextLink":"https://www.......com/v3/data?input1=value1,value2,value3,value4,value5,value6∈put2=Value7☆t-date=2daysAgo&end-date=1daysAgo☆t-index=11&max-results=10","profileInfo":{"profileId":"xxxxxx","accountId":"xxxxxx","webPropertyId":"xxxxxx","internalWebPropertyId":"xxxxx","profileName":"xxxxxx","tableId":"xxxxxx"},"containsSampledData":false,"columnHeaders":[{"name":"value1,"columnType":"input1","dataType":"STRING"},{"name":"value2","columnType":"input1","dataType":"STRING"},{"name":"value3","columnType":"input1","dataType":"STRING"},{"name":"value4","columnType":"input4","dataType":"STRING"},{"name":"value5","columnType":"input1","dataType":"STRING"},{"name":"value6","columnType":"input1","dataType":"STRING"},{"name":"value7","columnType":"input2","dataType":"INTEGER"}],"totalsForAllResults":{"XXX:sessions":"3034"},"rows":[["0007a676-0a92-48b1-a5b9-803d93be667f","US","test page","www.xxxxxx.us","/nl/ns","20170918","0"],["0007a676-0a92-48b1-a5b9-803d93be667f","CN","Installment","www.xxxxxx.CN","/nl/plat","20170918","0"],["0007a676-0a92-48b1-a5b9-803d93be667f","CH","Profession","www.xxxxx.CH","/nl/pro","20170918","0"],["0007a676-0a92-48b1-a5b9-803d93be667f","IN","Achievement,","www.xxxxx.in","/","20170918","1"],

Any inputs on what kind of groovy script needs to be added to get desired structure.

Thanks and regards,

Dinesh.

Add comment
10|10000 characters needed characters exceeded

  • Former Member

    Hi Dinesh,

    The sample data you have provided seems to be wrong.

    Please attach a text file with correct & formatted json sample content.

    I will use that to try and convert it into an XML using SCPI.

    Regards,

    Prasanna

  • Former Member Former Member

    Hi Prasanna,

    Thanks for helping out.

    Validated input:

    { "kind": "analytics#Data", "id": "https://www.abc.com/v3/data?ids=abc∈put1=value1,value2,value3,value4,value5,value6∈put2=Value7☆t-date=2daysAgo&end-date=1daysAgo&max-results=10", "query": { "start-date": "2daysAgo", "end-date": "1daysAgo", "ids": "xxx", "input1": "value1,value2,value3,value4,value5,value6", "input2": ["Value7"], "start-index": 1, "max-results": 10 }, "itemsPerPage": 10, "totalResults": 8568, "selfLink": "https://www......com/v3/data?ids=xxx∈put1=value1,value2,value3,value4,value5,value6∈put2=Value7☆t-date=2daysAgo&end-date=1daysAgo&max-results=10", "nextLink": "https://www.......com/v3/data?input1=value1,value2,value3,value4,value5,value6∈put2=Value7☆t-date=2daysAgo&end-date=1daysAgo☆t-index=11&max-results=10", "profileInfo": { "profileId": "xxxxxx", "accountId": "xxxxxx", "webPropertyId": "xxxxxx", "internalWebPropertyId": "xxxxx", "profileName": "xxxxxx", "tableId": "xxxxxx" }, "containsSampledData": false, "columnHeaders": [{ "name": "value1", "columnType": "input1", "dataType": "STRING" }, { "name": "value2", "columnType": "input1", "dataType": "STRING" }, { "name": "value3", "columnType": "input1", "dataType": "STRING" }, { "name": "value4", "columnType": "input4", "dataType": "STRING" }, { "name": "value5", "columnType": "input1", "dataType": "STRING" }, { "name": "value6", "columnType": "input1", "dataType": "STRING" }, { "name": "value7", "columnType": "input2", "dataType": "INTEGER" }], "totalsForAllResults": { "input2": "3034" }, "rows": [ ["0007a676-0a92-48b1-a5b9-803d93be667f", "US", "test page", "www.xxxxxx.us", "/nl/ns", "20170918", "0"], ["0007a676-0a92-48b1-a5b9-803d93be667f", "CN", "Installment", "www.xxxxxx.CN", "/nl/plat", "20170918", "0"], ["0007a676-0a92-48b1-a5b9-803d93be667f", "CH", "Profession", "www.xxxxx.CH", "/nl/pro", "20170918", "0"], ["0007a676-0a92-48b1-a5b9-803d93be667f", "IN", "Achievement,", "www.xxxxx.in", "/", "20170918", "1"] ] }

    Thanks and regards,

    Dinesh.

  • Get RSS Feed

1 Answer

  • Sep 20, 2017 at 08:05 AM

    Hello Dinesh,

    As per my understanding you can convert the JSON ( only level of hierarchy) to XML.You cant use standard converter to convert multi hierarchy JSON to XML.

    You might need to use a script to do the same.

    Regards,

    Sriprasad Shivaram Bhat

    Add comment
    10|10000 characters needed characters exceeded