Serialize entity to Json in middleware/core service

Hey guys,

I’m trying to write a service in which I eventually want to serialize an entity/object to a Json string. I’ve come across several topics with different solutions, but I cant seem to connect the dots.

One topic talks about the JSONConverter which the REST API uses, but I cant seem to use that one in the core part. (com.haulmont.cuba.restapi.JSONConverter ?).

The manual describes the EntityImportExportAPI for the middleware, but it requires a Datasource to be converted, which I don’t have in there, and can’t create.

What am I missing here ?

Hi

check EntitySerializationAPI, it is defined in the global module, so accessible in every layer.

See an example in my userprofile component here: cuba-component-user-profile/UserProfileControllerManager.java at master · cubait/cuba-component-user-profile · GitHub

Paolo

1 Like

Hmm, I somehow read past over that one in the manual.

Thanks for pointing it out!