title: API Gateway Request map format for json with single quotes
body: <p>I'm working in cdk and producing an api gateway resource. I need to supply a request template that looks like this:</p>
  <pre><code>$util.escapeJavaScript(data).replaceAll(&quot;\\'&quot;,&quot;'&quot;)
  </code></pre>
  <p>but I can't figure out how to format this in the typescript cdk code:. Here's the error code when you just blindly type it in without making any effort:</p>
  <pre><code>lib/factory/api-gateway/api-gw-factory.ts:119:68 - error TS1127: Invalid character.
  
  119       bodyjson : &quot;$util.escapeJavaScript($input.body).replaceAll(&quot;\\'&quot;,&quot;'&quot;)&quot;,
      
  lib/factory/api-gateway/api-gw-factory.ts:119:74 - error TS1005: ':' expected.
  
  119       bodyjson : &quot;$util.escapeJavaScript($input.body).replaceAll(&quot;\\'&quot;,&quot;'&quot;)&quot;,
  </code></pre>
  <p>doesn't work obviously. I've tried a heap of other things. I've found that the formatting I need to get the code to compile just gets fed straight into the output template.</p>
  <p>I.e. the following compiles, but the escape characters end up in the generated output...</p>
  <pre><code>bodyjson : &quot;$util.escapeJavaScript($input.body).replaceAll(\&quot;\\'\&quot;,\&quot;'\&quot;)&quot;,
  </code></pre>
  <p>leads to :</p>
  <pre><code>{
      &quot;bodyjson&quot;: &quot;$util.escapeJavaScript($input.body).replaceAll(\&quot;\\'\&quot;,\&quot;'\&quot;)&quot;,
  </code></pre>
  <p>in the template... Which is clearly not sensible apache velocity.</p>
  <p>I even tried this:</p>
  <pre><code>const testStr = &quot;$util.escapeJavaScript($input.json('$')).replaceAll(\&quot;\\'\&quot;,\&quot;'\&quot;)&quot;;
  const escapedStr = testStr.replace(/\&quot;/g,'&quot;');
  
  let requestTemplate: {[index: string]:any} = {
    &quot;bodyjson&quot; : escapedStr, // escapes reappear in template! 
  </code></pre>
  <p>but the escape characters reappear in the cursed template afterwards!</p>
  <p>How do I achieve the desired output format?</p>