Parse Mendix entity object to json string in Java Action code

0
In a java action, I set an entity as one of the params. In the java action, I added jackson to help me doing some json parsing work. I need to parse this entity param into json string for further using in the java action. code as below, very simple. the requestBody is instance of a MENDIX_MODULE.proxies.MENDIX_ENTITY    ObjectMapper objectMapper = new ObjectMapper();  String requestBodyString = objectMapper.writeValueAsString(requestBody);   however I’m getting Infinite recursion (StackOverflowError). can anyone help me with this? thanks.  
asked
2 answers
1

Hank,

Mendix has the ability to parse an entity into a json string natively.  Perhaps you can parse the string in a microflow and pass the resulting json to your Java action?

Hope that helps,

Mike

answered
1

Hi Hank, 

You can achieive this via microflow.

Create a Export mapping and Message Definition for the entity which you need to convert them as a JSON String. 

Create a microflow add an activity Export Mapping and call the export mapping which you created and pass the object as parameter and Set the content type as JSON and Return variable as String. 

Now, this activity will return the entity data in the form of JSON String. 

Then you can pass this string to javaaction easily.

answered