IC SunsetThe developerWorks Connections platform will be sunset on December 31, 2019. On January 1, 2020, this forum will no longer be available. More details available on our FAQ.
Topic
  • 7 replies
  • Latest Post - ‏2017-08-08T10:46:15Z by HermannSW
Rajesh_Ale
Rajesh_Ale
115 Posts

Pinned topic JSON to (JSONX or XML) using gateway script

‏2015-03-17T20:50:45Z |

Is there any way  to convert JSON to (JSONX or XML ) in Gateway Script  ,, not by Convert Query Params to XML Action

.. I cannot use XSLT or convert Queryparams .. I have to use only GatewayScript (js) only.. does anyone have any idea from converting

JSON to (JSONX or XML) using gatewayscript (js)

please help me 

  • HermannSW
    HermannSW
    8749 Posts

    Re: JSON to (JSONX or XML) using gateway script

    ‏2015-03-18T00:09:51Z  

    First you need to define what mapping you want, there is no default JSON to XML mapping.

    After you have defined a mapping (or do have an almost complete set of JSON input/XML output pairs)


    Or try

    The last links define the mapping for you, but that may be OK in case you are flexible and can accept the generated XML.


    Hermann.

  • SunnyG87
    SunnyG87
    100 Posts

    Re: JSON to (JSONX or XML) using gateway script

    ‏2015-06-26T05:44:46Z  
    • HermannSW
    • ‏2015-03-18T00:09:51Z

    First you need to define what mapping you want, there is no default JSON to XML mapping.

    After you have defined a mapping (or do have an almost complete set of JSON input/XML output pairs)


    Or try

    The last links define the mapping for you, but that may be OK in case you are flexible and can accept the generated XML.


    Hermann.

    Hermann,

    Firmware v 7.2 talks about easily transform JSON to XML with Gateway script. What are your thoughts on that? 

  • librah
    librah
    9 Posts

    Re: JSON to (JSONX or XML) using gateway script

    ‏2015-06-29T03:59:58Z  
    • SunnyG87
    • ‏2015-06-26T05:44:46Z

    Hermann,

    Firmware v 7.2 talks about easily transform JSON to XML with Gateway script. What are your thoughts on that? 

    Hermann's comment still holds.  

    GatewayScript in v7.2 provides XML related APIs enabling you to read in XML data, parse string into XML, serialize XML object to string or send to output.    From XML to JSON, you can use the DOM/XPATH API to traverse XML and compose the JSON object on the fly.    And from JSON to XML, you still need to traverse the JSON object and compose XML/string using the materials mentioned in Hermann's comment.    There is no one single API, yet, that you can use for converting JSON<=>XML.

  • HermannSW
    HermannSW
    8749 Posts

    Re: JSON to (JSONX or XML) using gateway script

    ‏2015-06-29T06:42:49Z  

    Hi Sunny,

     

    adding to what Libra said, the performance of a JSON2XML solution based on new v7.2 XML APIs will be much better than that of a nodejs only solutions I pointed to -- the GatewayScript XML API provided with v7.2 is highly optimized and integrated into the firmware.


    So what you need first is an idea of the transformation you are interested in -- there are arbitrary many transformations from JSON to XML. You need to know the structure of the JSON input (all JSON or a specific subset), and you need to know what XML should be generated for a given JSON input.



    Hermann.
     

  • HermannSW
    HermannSW
    8749 Posts

    Re: JSON to (JSONX or XML) using gateway script

    ‏2015-07-14T07:56:49Z  
    This reply was deleted by Jaango 2015-07-15T04:08:13Z. Reason for deletion: Deleting

    Hi,

    what I did in the past was

    • npm install on my Thinkpad
    • copy over needed files to "local:" folder on DataPower


    Hermann.

  • classic@ankita
    classic@ankita
    5 Posts

    Re: JSON to (JSONX or XML) using gateway script

    ‏2017-08-07T10:35:08Z  
    • HermannSW
    • ‏2015-07-14T07:56:49Z

    Hi,

    what I did in the past was

    • npm install on my Thinkpad
    • copy over needed files to "local:" folder on DataPower


    Hermann.

    Hi Hermann,

     

    Can you please help me with the files which need to be included for converting JSON to xml using gatewayscript.

    It will be helpful if you can provide a sample for the same or the documentation if any.

     

    Also,please suggest if I can use this policy mentioned in the link.Is datapower have inbuilt policy.I am using 7.5 version of datapower.

    https://www.ibm.com/support/knowledgecenter/en/SSMNED_5.0.0/com.ibm.apic.toolkit.doc/rapim_ref_ootb_policyjson2xml.html

     

    Thanks in advance.

  • HermannSW
    HermannSW
    8749 Posts

    Re: JSON to (JSONX or XML) using gateway script

    ‏2017-08-08T10:46:15Z  

    Hi Hermann,

     

    Can you please help me with the files which need to be included for converting JSON to xml using gatewayscript.

    It will be helpful if you can provide a sample for the same or the documentation if any.

     

    Also,please suggest if I can use this policy mentioned in the link.Is datapower have inbuilt policy.I am using 7.5 version of datapower.

    https://www.ibm.com/support/knowledgecenter/en/SSMNED_5.0.0/com.ibm.apic.toolkit.doc/rapim_ref_ootb_policyjson2xml.html

     

    Thanks in advance.

    The above thread is on DataPower JSON to JSONX conversion in GatewayScript, you seem to have an API Connect issue. Please don't hijack unrelated, aged threads. You may have more luck with API Connect questions here:
    https://developer.ibm.com/answers/smart-spaces/11/api.html

    Hermann.