0

After migrating to Jersey 2.0, my REST service seems to serve up this boolean flag in a slightly different manner. (I can provide the Service code as well if it helps, but this seems pretty standard and just needs interperated different on the client)

{"incompleteFlag":{"valueType":"TRUE"}}

I think this is because the way the JSON is build was changed with the migration, but I used to interperate this fine using Java code like such:

boolean incompleteFlag = false;
JSONObject json = new JSONObject(response.readEntity(String.class));

//At this point in debugging, checking json variable looks good, as we seen above

incompleteFlag = json.getBoolean("incompleteFlag");

Obviously this does not work anymore since we now have a valueType to interperate. Any way to simply get this true/false flag? I've been trying to search out there, but not much luck.

Edit - Adding service code as well. I mentioned this in a comment, but I was having some serialization issues when trying to use the JSONObject instead of JsonObject from javax and that is why that aspect changed with the migration.

@GET
@Path("{employeeId}")
@Produces(MediaType.APPLICATION_JSON)
public Response produceJSON(@PathParam("employeeId") String empId){

    System.out.println("Checking emp forms for " + empId);

    boolean incompleteFlag = TAFactory.getHome().getIncompleteEmployeeForms(empId);

    JsonObject myObject = Json.createObjectBuilder().add("incompleteFlag", incompleteFlag).build();         
    return Response.ok(myObject, MediaType.APPLICATION_JSON).build();
}
aohm1989
  • 401
  • 1
  • 8
  • 19
  • May have more details soon, think I imported the JsonObject from javax in the service and not JSONObject from Jettison... – aohm1989 Jul 18 '14 at 12:53
  • Scratch that, I now remember why I did that. I was getting a No serializer found for the Jettison jars and switched it at that point. Might need to also use the javax JsonObject in the above code as well... – aohm1989 Jul 18 '14 at 12:59

0 Answers0