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.

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:, java.lang.Class,…)

Custom GsonBuilder is created:
with custom entity deserializer:

Processed entities are temporarily stored in a thread-local variable during deserialization: