title: Jackson: Keeping escaped strings as they are after deserialization/serialization
body: <p>I already have a JSON string (automatically treated as JsonNode), with many string fields.
  All values for any string field are already escaped if there are quotes or other characters in it.
  Whether I deserialize/transform the JSON / JsonNode, every string in the POJO is unescaped.
  After serialization of the POJO all string values are escaped again.
  If I escape any string value by hand, all values are double escaped after serialization.</p>
  
  <p><strong>Question</strong>: Is there a way via mapper settings or class/property annotations to keep the input as it is without losing the backslashes after deserialization?</p>
  
  <p>Here is a pseudo example of what I need / what I'm doing:</p>
  
  <p>A request comes in:</p>
  
  <pre><code>{
      "dateFrom": "2005-01-01",
      "dateTo": "2016-07-22",
      "queryString": "cheese steak jimmys \"cheesesteakjimmys\""
  }
  </code></pre>
  
  <p>After this I want to query some data but this would lead to database errors, because via request.getQueryString() I get: </p>
  
  <pre><code>"cheese steak jimmys "cheesesteakjimmys""
  </code></pre>
  
  <p>If I escape it in <em>setQueryString()</em> at deserialization this would lead to the below result after writing it back:</p>
  
  <pre><code>{
      "timestamp": 144412412515,
      "body": {
          "dateFrom": "2005-01-01",
          "dateTo": "2016-07-22",
          "queryString": "cheese steak jimmys \\\"cheesesteakjimmys\\\""
      }
  }
  </code></pre>
  
  <p>The wanted output in <em>getQueryString()</em>:</p>
  
  <pre><code>"cheese steak jimmys \"cheesesteakjimmys\""
  </code></pre>
  
  <p>Jackson-Version: 2.8.0</p>
  
  <p>Thank you in advance,
  -Y-</p>
  
  <p><em>UPDATE</em></p>
  
  <pre><code>//the incoming request POJO
  @JsonInclude(JsonInclude.Include.NON_NULL)
  public class AbstractRequest {
      private String queryString;
      private String dateFrom;
      private String dateTo;
  
      public String getQueryString() {
          return queryString;
      }
  
      public void setQueryString(String queryString) {
          this.queryString = queryString;
      }
  
      public String getDateFrom() {
          return dateFrom;
      }
  
      public void setDateFrom(String dateFrom) {
          this.dateFrom = dateFrom;
      }
  
      public String getDateTo() {
          return dateTo;
      }
  
      public void setDateTo(String dateTo) {
          this.dateTo = dateTo;
      }
      //toString()
  }
  </code></pre>
  
  <p>The persisted object with the body of the executed request:</p>
  
  <pre><code>@JsonInclude(JsonInclude.Include.NON_NULL)
  public class PersistedRequest {
      private long timestamp;
      private AbstractRequest body;
  
      public long getTimestamp() {
          return timestamp;
      }
  
      public void setTimestamp(long timestamp) {
          this.timestamp = timestamp;
      }
  
      public AbstractRequest getBody() {
          return body;
      }
  
      public void setBody(AbstractRequest body) {
          this.body = body;
      }
      //toString()
  }
  </code></pre>
  
  <p>Parsing the initial request into POJO:</p>
  
  <pre><code>JsonNode body = request().body().asJson();
  AbstractRequest request = null;
  try {
      request= mapper.treeToValue(body, AbstractRequest.class);
  } catch (Exception e) {
      Logger.error("Cannot Parse request", e);
  }
  
  
  //body.toString() gives this output
  //{"datefrom":"2005-01-01","dateTo":"2016-07-22","queryString":"cheese steak jimmys \"cheesesteakjimmys\""}
  </code></pre>
  
  <p>request.toString() brings:</p>
  
  <pre><code>//AbstractRequest{queryString='cheese steak jimmys "cheesesteakjimmys"', dateFrom='2005-01-01', dateTo='2016-07-22'}
  //NO backslashes anymore
  //querying for some data via request.getQueryString() would now result in data base errors
  </code></pre>
  
  <p>Parsing the request back to persist it:</p>
  
  <pre><code>PersistedRequest persistedRequest = new PersistedRequest();
  persistedRequest.setBody(request);
  JsonNode persistedRequestAsNode = mapper.valueToTree(persistedRequest);
  //persistedRequestAsNode.ToString() for brevity brings
  //{"body":{"queryString":"cheese steak jimmys \"cheesesteakjimmys\""}}
  
  //DAO.create(persistedRequestAsNode)
  </code></pre>