title: How to convert JSON to a string with escape characters
body: <p>I am new to JMeter java and Minidev. I am working on this existing module where I have to use minidev libraries I need to convert a JSON form non-indented format to a string format in Jmeter. The API requires a String representation of the JSON due to some characters.</p>
  
  <p>To give an example, I have <code>{"Item":"Value","MyList":["A","B","C"]}</code> which I want to convert as <code>"{\"Item\":\"Value\",\"MyList\":[\"A\",\"B\",\"C\"]}"</code></p>
  
  <p>I have tried using <code>JSONObject.toString()</code> or <code>JSONObject.toJSONString()</code> however this does not give me desired results. I am using Jmeter 5 with Java 12</p>
  
  <p>I did not find any good solution in short time so right now I am using below code however I would love to do it the right way.</p>
  
  <pre><code>String postJSON = root.toJSONString().replace("\"","\\\"");
  postJSON = postJSON.replace("{","\"{");
  postJSON = postJSON.replace("}","}\"");
  </code></pre>