This block of code essentially takes a JAXB Object and turns it into a JSONObject
StringWriter stringWriter = new StringWriter();
marshaller.marshal(jaxbObj, stringWriter);
try {
JSONObject jsonObject = XML.toJSONObject(stringWriter.toString());
resp.getOutputStream().write(jsonObject.toString(2).getBytes());
} catch (JSONException e) {
throw new ServletException("Could not parse JSON",e);
}
Unfortunately, this transformation doesn't turn, say, a String like "true" into a boolean, leaving the poor front end guy to do it.
I would think that I want to somehow map over the values in the JSONObject, calling stringToValue on each. I have a feeling there is a better way. Any ideas?