How to stringify json in camunda modeler

Hello, fellow Camunda enthusiasts!

I’m excited to dive into the world of Camunda with you all! I have a question regarding stringifying input variables of a map in Camunda Modeler, specifically when dealing with JSON.

Task: I need to convert a map’s input variables, which are in JSON format, into string (value of taxpayer in screenshot)


.

Hello my friend!

I like to use SpinJson’s S() method.
Take a look at the links below, which may help you, and with this you will be able to work with your object within camunda itself, accessing the properties through .prop().

https://javadoc.io/static/org.camunda.spin/camunda-spin-core/1.5.6/org/camunda/spin/Spin.html#S(java.lang.Object)

I hope this helps.
William Robert Alves

Hi William, as always thank you for your response). Actually i whant to stringifye it in Camunda modeler. In this example I mean the value of map ${taxpayer}, will it be possible to do it ?

1 Like

Have you tried using JSON.stringify() for what you need my bro?

I believe you can do something like:
${JSON.stringify(taxpayer)}

Try using this, and let me know if it worked and if this is what you needed.

William Robert Alves

it dose not worked

org.camunda.bpm.engine.ProcessEngineException: Unknown property used in expression: ${JSON.stringify(taxpayer)}. Cause: Cannot resolve identifier 'JSON'
Tue, Aug 1 2023 10:00:25 am at org.camunda.bpm.engine.impl.el.JuelExpression.getValue(JuelExpression.java:63) ~[camunda-engine-7.19.0.jar!/:7.19.0]
Tue, Aug 1 2023 10:00:25 am at org.camunda.bpm.engine.impl.el.JuelExpression.getValue(JuelExpression.java:51) ~[camunda-engine-7.19.0.jar!/:7.19.0]
Tue, Aug 1 2023 10:00:25 am at org.camunda.bpm.engine.impl.el.ElValueProvider.getValue(ElValueProvider.java:40) ~[camunda-engine-7.19.0.jar!/:7.19.0]
Tue, Aug 1 2023 10:00:25 am at org.camunda.bpm.engine.impl.core.variable.mapping.value.MapValueProvider.getValue(MapValueProvider.java:40) ~[camunda-engine-7.19.0.jar!/:7.19.0]
Tue, Aug 1 2023 10:00:25 am at org.camunda.bpm.engine.impl.core.variable.mapping.InputParameter.execute(InputParameter.java:46) ~[camunda-engine-7.19.0.jar!/:7.19.0]
Tue, Aug 1 2023 10:00:25 am at org.camunda.bpm.engine.impl.core.variable.mapping.IoParameter.execute(IoParameter.java:51) ~[camunda-engine-7.19.0.jar!/:7.19.0]

actually I solve it by creating intermediate script task and stringifying the JSON Object
Screenshot from 2023-08-01 15-35-34
Screenshot from 2023-08-01 15-36-02

1 Like

Haaaa I had understood that you didn’t want to use Java and the ObjectMapper is part of the Jackson/Java lib.

I got it wrong.
I’m glad you made it!

William Robert Alves

1 Like

I guess its because of my bad explanation, )) anywhere Thank you for your time and response

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.