ho la seguente classe:JSON - Impossibile serializzare JSONObject entro oggetto utilizzando Jackson
class A{
String abc;
String def;
// appropriate getters and setters with JsonProperty Annotation
}
e chiamo Jacksons objectMapper.writeValueAsString(A)
che funziona bene.
Ora ho bisogno di aggiungere un altro membro di istanza:
class A{
String abc;
String def;
JSONObject newMember; // No, I cannot Stringify it, it needs to be JSONObject
// appropriate getters and setters with JsonProperty Annotation
}
ma quando ho serializzare, sto diventando un'eccezione:
org.codehaus.jackson.map.JsonMappingException: No serializer found for class org.json.JSONObject and no properties discovered to create BeanSerializer
ho provato JSONNode ma è dato in uscita come {outerjson: " {innerjson} "} non {outerjson: {innerjson}}.
È possibile utilizzare Jackson per ottenere l'output di cui sopra, ovvero JSONObject in JSONObject?
È possibile visualizzare l'output previsto da un dato input? –
Perché non utilizzare il '' 'ObjectNode''' fornito da Jackson? – oceansize