Layer7 API Management

  • 1.  Escaping double quotes for a Json response within Policy Manager

    Posted Oct 06, 2015 11:05 PM

    Hi.

     

    I am using a Perform JDBC Query which returns a description from the database into a context variable ${jdbcQuery.description}

     

    I include this in a JSON response, however, there are issues when there are double quotes in the description that are not escaped.

     

    What's the best way to escape these (e.g.  \" ) using the Policy Manager Assertions. I have tried using the Evaluate Regular Expression but not sure if I can do this.

     

    e.g. when the contents of my context variable ${jdbcQuery.description} is

    This is my "Example" description


    I would replace this with

    This is my \"Example\" description


    The only other way I can think of is that I do a split variable on " and then a join variable using \" but would this be performance 'costly'?


    I would appreciate advise/help.


    Many Thanks,

    Paul



  • 2.  Re: Escaping double quotes for a Json response within Policy Manager
    Best Answer

    Posted Oct 06, 2015 11:30 PM

    Just to add I tried the following and it works OK

    example_split.PNG

    Is this 'OK' or is there a 'better' way to do this?