I'm not sure if this type of problem was already asked. I couldn't find, so asking
I have a POJO
Class A {
int id;
Object data;
//getter and setters
}
I set org.json.JSONObject type json into data
Option 1: When I set data to object directly, I get an error from ObjectMapper when doing
objectMapper.writeValueAsString(anInstanceOfA);
Error: InvalidDefinitionException: No serializer found for org.json.JSONObject
{ I assume the problem is between fasterxml and org.json }
Option 2: If I use toString on JSONObject before setting to an instance of A, I see escape character in the output. The output is unacceptable. Can't sacrifice JSON formatting and structure
Is there a way to leave already JSON structured element as-is, with less conversions?