App Connect

Expand all | Collapse all

DETACH and ATTACH

  • 1.  DETACH and ATTACH

    Posted Tue July 27, 2021 01:25 PM
    Hi Team,
           I have used DETACH and ATTACH for adding and removing xml Element. It works fine with XML message.
           I would like to know is there anything for manipulating json like removing one or more keys in 
           InputRoot.JSON.Data and attaching the updated InputRoot.JSON.Data to OutputRoot.JSON.Data

        Any help will be greatly appreciated!!



    ------------------------------
    SELVAKUMAR ANANTHARAJ
    ------------------------------


  • 2.  RE: DETACH and ATTACH

    Posted Wed July 28, 2021 04:52 AM

    Hi,

    Yes this works with JSON domain just as it does with XML, so lets say we have an input message of

    { "Orders": [  [ { "one": 1}, { "two": 2} ],
                             [ {"a": 11} ]  ]  }

    We could use ESQL

        CALL CopyEntireMessage();
        DECLARE ref1 REFERENCE TO OutputRoot.JSON.Data.Orders.Item[1].Item[2];
        DETACH ref1;
        ATTACH ref1 TO OutputRoot.JSON.Data.Orders.Item[2] AS LASTCHILD;

    To move the first array second entry to the second

      {  "Orders":  [  [ {"one":1} ], 
                        [ {"a":11}, {"two":2} ]  ] }

    HTH



    ------------------------------
    Martin Boag
    Software Developer
    IBM
    ------------------------------



  • 3.  RE: DETACH and ATTACH

    Posted Fri July 30, 2021 03:01 AM
    Thanks Martin Boag

    ------------------------------
    SELVAKUMAR ANANTHARAJ
    ------------------------------