API Connect

API Connect

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  Need Multiline text into single line JSON format

    Posted Thu May 05, 2022 02:15 AM
    Hello Team,

    We need to convert multiline plaintext data to singleline JSON format to parse data in IBM API connect v10.
    We are getting multiline JSON format data which are getting error while parsing.
    Please find below scenario.

    Eg:
    Plaintext:
    xyz{"ww
    yy"}

    JSON :
    xyz{"WW YY"}

    ------------------------------
    Jyoti Yadav
    ------------------------------


  • 2.  RE: Need Multiline text into single line JSON format

    Posted Thu May 05, 2022 09:13 AM

    Hi Jyoti,

    The newline character (hex 0D) needs to be replaced with the characters \n.  In GatewayScript, use

    let jsonValueString = JSON.stringify(textValueString);

    which should do the escaping for you.

    Regards,

    Steve



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM
    ------------------------------