Layer 7 API Management

Expand all | Collapse all

Not able to convert Json to xml with json having prefix?

Jump to Best Answer
  • 1.  Not able to convert Json to xml with json having prefix?

    Posted 12-18-2017 07:59 AM

    I am not able to convert below json into Xml and getting bound error(Standard transformation) and Error in XML generated (using JsonML transformation).

    I am using Json Transformation assertion to do so.

     

    Can you please help me out to convert it? I have tried adding prefix in root element "info:SessionEvent" but it didn't help.

     

    {
    "info:SessionEvent": {
    "-xmlns:info": "urn:Namespaces.xyz.Com:Nrm:Nro:Session:v0001",
    "info:SessionId": "128987732",
    "info:SessionDetails": {
    "info:SessionCoreDetails": {
    "info:SessionID": "null",
    "info:SessionName": "1027593-Test Activity template 1",
    "info:SessionType": "null"
    },
    "info:ParentReferences": {
    "info:ProjectRecordName": "1000003 - Dev",
    "info:WorkPlanRecordName": "1000934-AJ-Congo updated for 1076-AJ",
    "info:RecordName": "1027593-Test Activity template 1",
    "info:Site": "Congo updated for 1076",
    "info:Customer": "xyz"
    },
    "info:AssigneeReference": {
    "info:AssigneeFullName": "Xyz user",
    "info:AssigneePhone": "null",
    "info:AssigneeEmail": "test@test.com"
    }
    }
    }
    }



  • 2.  Re: Not able to convert Json to xml with json having prefix?
    Best Answer

    Posted 12-18-2017 09:24 AM

    Hi Apurva,

     

    The problem with this is that the JSON string that's being provided does not follow well-known encoding for XML. XML

    distinguishes between attributes and subtags, but JSON has no such distinction.

     

    Because of this problem, different ways have come up to shoehorn that distinction into JSON, and none of them are intuitive or straightforward.


    i.e: http://lists.xml.org/archives/xml-dev/201506/msg00024.html

     

    "Be aware that more complex XML structures (such as namespace, attributes) may not be transformed correctly."

    https://docops.ca.com/ca-api-gateway/9-2/en/policy-assertions/assertion-palette/message-validation-transformation-assertions/apply-json-transformation-assertion/

     

    The same issue is seen on 3rd party websites: Free Online JSON to XML Converter - FreeFormatter.com 

     

    Regards,
    Joe