Deserialize - COMPACT_REPEATED_ENTITIES

Hi,
I have custom REST controller and Im using EntitySerializationAPI to serialize response…
Im using: EntitySerializationOption.COMPACT_REPEATED_ENTITIES.

Short example of serializing:
String response = entitySerializationAPI.toJson(MY_OBJECT, null, EntitySerializationOption.COMPACT_REPEATED_ENTITIES);

My question is, how to deserialize result of this code using jackson or gson?
I need to deserialize it in no cuba application.

Hi,
Well, standard deserialization methods of Jackson / Gson should work, don’t they?

Dont deserialize object correctly when there is only id.

This is my question how to do this correctly.

Well, you can take approach implemented in the EntitySerializationAPI.
The code is open source and available for investigation and copying.

Deserialization method: com.haulmont.cuba.core.app.serialization.EntitySerialization#objectFromJson(java.lang.String, java.lang.Class, com.haulmont.cuba.core.app.serialization.EntitySerializationOption…)

Custom GsonBuilder is created: com.haulmont.cuba.core.app.serialization.EntitySerialization#createGsonForDeserialization
with custom entity deserializer: com.haulmont.cuba.core.app.serialization.EntitySerialization.EntityDeserializer

Processed entities are temporarily stored in a thread-local variable during deserialization: com.haulmont.cuba.core.app.serialization.EntitySerialization#context