title: JAX-RS (Jersey): String from JSON request body still escaped
body: <p>This is driving me crazy. I'm working on a REST endpoint in JAX-RS (Glassfish / Jersey). I have a method that's supposed to receive a String, store it and return it. The entire endpoint should consume and produce JSON. But every time I post a String to the method, it's handed to me in escaped form. E.g. if I post:</p>
  
  <pre><code>fetch("http://localhost:8080/myapp/rest/myresource", {
    method: "post",
    credentials: 'same-origin',
    body: JSON.stringify("test\ntest"),
    headers: {
      "Content-Type": "application/json"
    }
  })
  </code></pre>
  
  <p>and the resource is:</p>
  
  <pre><code>@Produces(MediaType.APPLICATION_JSON)
  @Consumes(MediaType.APPLICATION_JSON)
  public class MyResource {
  
      @POST
      public String set(@NotNull String value){
          // store it
          return storedValue;
      }
  }
  </code></pre>
  
  <p>then what is stored, and return to the client, is:</p>
  
  <pre><code>"test\ntest"
  </code></pre>
  
  <p>If, however, I wrap the String in an object:</p>
  
  <pre><code>fetch("http://localhost:8080/myapp/rest/myresource", {
    method: "post",
    credentials: 'same-origin',
    body: JSON.stringify({value: "test\ntest"}),
    headers: {
      "Content-Type": "application/json"
    }
  })
  </code></pre>
  
  <p>with resource</p>
  
  <pre><code>@Produces(MediaType.APPLICATION_JSON)
  @Consumes(MediaType.APPLICATION_JSON)
  public class MyResource {
  
      @XmlRootElement
      public static class Wrapper {
          public String value;
      }
  
      @POST
      public String set(@NotNull Wrapper wrapper) {
          String value = wrapper.value;
          // store it
          return storedValue;
      }
  }
  </code></pre>
  
  <p>then the value that's stored and returned to the client is</p>
  
  <pre><code>test
  test
  </code></pre>
  
  <p>Am I missing something?</p>
  
  <pre><code>Glassfish 4.1.1
   - jersey 2.10.4-0
   - json 1.0-0.1
  </code></pre>