JSON variables strategy

As I understand Flowable supports JSON tyle process instance variables. That variable type is made by HTTP Task when related property is set to True. It’s convinient for ${object.nodename} notation in expressions and for collection-initiated multi-instance flows. JSON variable also returns JSON text form via API and Admin app.

I figured out how to create such variable type in JS script:

var JsonNodeFactory = new com.fasterxml.jackson.databind.ObjectMapper
var myJson= [{"value":"1"}, {"value":"2"}];
ObjectMapper.readTree (JSON.stringify(myJson)));

Is my approach correct?

I also don’t know how to use existing JSON variable in JS script to modify the object, extract node values, etc. Could anybody toss me any example?

Hey @blinkin,

Yes your approach for creating a json variable from a script is correct.

In scripts you can use the JsonNode API for modifying variables.

e.g. Lets take that you have the following as a JSON variable named customer:

    name: 'kermit',
    age: 30,
    address: {
        city: 'New York'

You can access values using:

var city = customer.path("address").path("city").asText();

You can modify values using:

customer.path("address").put("street", "Sesame Street");
execution.setVariable("customer", customer);