I need to serialize a hierarchy of scala case classes as JSON to store them in a db. I am currently using json4s and it works quite well. However, when deserializing in Java jackson requires me to have an empty constructor for case classes (which doesn't exist).
The other option I tried is to define a deserialization function in my scala library, import it in the Java code and run it at runtime to read a string and build the relative class of the hierarchy. In this way I am able to reconstruct the object in the Java world. Afterwards, I want to return this object: if I return it as an object I am not able to serialize it correctly (jackson uses different logic than json4s); if I use my scala function, I am able to create a string and return it, but for some reasons it gets returned escaped:
"{\"jsonClass\":\"TimeExtremaConfig\",\"name\":\"payment_first_seen_hotel_id_on_agency\"}
Is there a better way to approach this problem? Either finding a way to deserialize case classes and use jackson all over the place or avoiding the escaping in the second option