Cannot set a json property with null value in camunda spin

I set an execution variable with null value in my process, and then get this variable and set on my json property using camunda spin, but when I did this, camunda returns the following error:

Can’t unambiguously select between fixed arity signatures [(java.lang.String, java.util.Map), (java.lang.String, org.camunda.spin.json.SpinJsonNode), (java.lang.String, java.util.List), (java.lang.String, java.lang.Number), (java.lang.String, java.lang.Boolean), (java.lang.String, java.lang.String)] of the method org.camunda.spin.impl.json.jackson.JacksonJsonNode.prop for argument types [java.lang.String, null]

Execution Listener (start)

execution.setVariable(‘nullValue’, null);

Execution Listener (end)

var customJson = S(‘{}’);
customJson.prop(“someValue”, execution.getVariable(“nullValue”));

testerrr.bpmn (2.8 KB)

Hi @kyle, faced the same propblem today. I just wanted to initialize a spin object with a null value.
Since the isNull() method exists (https://docs.camunda.org/manual/7.7/reference/spin/json/01-reading-json/) I find it akward not being able to do a simple:
customJson.prop("my_variable",null)

Community, any idea on how to initialize with null values?

Thanks, Ch.

@ChrisB this will return the empty json string as {}

SpinJsonNode jsonNode = JSON("{}");
String jsonString = jsonNode.toString();

Hi @aravindhrs, thanks, so I should I do it with the prop method?

@ChrisB @kyle, it should work. I have tried below, and the response is, {"nullValue":null}

SpinJsonNode jsonNode = JSON("{}");
String nullVal = null;
jsonNode.prop("nullValue", nullVal);
String jsonString = jsonNode.toString();
System.out.println(jsonString);

@aravindhrs, I probably should have mentionned that I’m writing the code in javascript in an inline scripting service task. Doing:

var customJson=S('{}')
customJson.prop("my_variable",null)
execution.setVariable("customJson",customJson)

Doesn’t work when running the instance, it might only be an bug with the javascript language…

@ChrisB I’m not a JavaScript fan. I have tested it in java code. In java it’s working fine.

Try like this,

var customJson = JSON('{}')

I can see this difference. Instead S() function use JSON() function. But I didn’t tested it.

Thanks for the reply, but JSON function is only supported in Java code, not in JavaScript
https://docs.camunda.org/manual/7.7/reference/spin/json/01-reading-json/