title: How to send a JsonObject in JerseyClient POST call?
body: <p>I have a POJO class, in which one element is of type JSONObject :</p>
  
  <pre><code> public static class TestRequest {
      org.json.JSONObject data;
    }
  </code></pre>
  
  <p>I want to send it over a POST call using JerseyClient. </p>
  
  <p>I tried this :</p>
  
  <pre><code> Client client = new Client();
      TestRequest request = new TestRequest();
      Map&lt;Long, String&gt; data = Maps.newHashMap();
      data.put(1L, "abc");
  
      JSONObject object = new JSONObject(data);
      request.setData(object);
  
      ClientResponse response = client.resource("http://localhost:18000/test/url")
              .accept(MediaType.APPLICATION_JSON_TYPE)
              .type(MediaType.APPLICATION_JSON_TYPE)
              .post(ClientResponse.class, request);
  </code></pre>
  
  <p>This fails with the error :
  No serializer found for class org.json.JSONObject</p>
  
  <p>So then I added this :</p>
  
  <pre><code>ObjectMapper mapper = new ObjectMapper();
  mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
  
  client.resource("http://localhost:18000/test/url")
              .accept(MediaType.APPLICATION_JSON_TYPE)
              .type(MediaType.APPLICATION_JSON_TYPE)
              .post(ClientResponse.class, mapper.writeValueAsBytes(request));
  </code></pre>
  
  <p>This does not fail, however in the request body which is actually being sent, has the <code>data</code> as an empty json.</p>
  
  <p>Any idea how to make it work ? </p>
  
  <p>The reason for keeping it a JsonObject is I will be getting this from one service and will pass it on to another without actually using it. So I don't want to model the internals of <code>data</code>.</p>