# Json structure and expression as output parameter

**URL:** <https://forum.flowable.org/t/json-structure-and-expression-as-output-parameter/3193>\
**Category:** Flowable Engine\
**Created:** [January 8, 2019, 1:17pm UTC](https://forum.flowable.org/t/json-structure-and-expression-as-output-parameter/3193 "2019-01-08T13:17:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![roman-mkh](https://avatars.discourse-cdn.com/v4/letter/r/7ba0ec/32.png) [@roman-mkh](https://forum.flowable.org/u/roman-mkh)\
**Post date:** [January 8, 2019, 1:17pm UTC](https://forum.flowable.org/t/json-structure-and-expression-as-output-parameter/3193/1 "2019-01-08T13:17:29Z")

</div>

Hello everybody,

I have a process-wide compex data object saved as process-instance variable named “processData” of type json (stored using JavaDelegate as JsonNode). Initial value looks like this:

```
{
  "customerNumber": 123456,
  "addresses": []
}

```

Then I have a ExecutionListener for some service-task which loads addresses.  
Execution listener has a outout parameter `addresses` (L-Value expression) like this: ${processData.addresses}.

In the java implementation of this listener I set the output value like this: `addressesExpression.setValue(addressesValue, execution)`

I experience here several problems:

1. Does not matter which java type I use for addressesValue (JsonNode, List, List, String) the value is injected into processData.addresses as string with all json escaped. So I do not have a json but a string.

2. Flowable process engine does not recognized changes in the `processData`, so it does not store the changes in DB. It is possible to access `processData.addreses` until transaction boundery (user task, async task). After it the “processData” is reset to its initial value (the value it was stored for the first time).

Is that a bug or is there a way do it right?

---

<div class="post-metadata">

**Author:** ![martin-schaefer](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/martin-schaefer/32/987_2.png) [@martin-schaefer](https://forum.flowable.org/u/martin-schaefer)\
**Post date:** [January 8, 2019, 8:58pm UTC](https://forum.flowable.org/t/json-structure-and-expression-as-output-parameter/3193/2 "2019-01-08T20:58:05Z")

</div>

Hi,

I think Flowable does not support JSON objects in such a transparent way. I’ve also played around with this and the only way to receive a JSON process variable in a method call was to declare the parameter as com.fasterxml.jackson.databind.JsonNode:

```
public void receive(JsonNode invoiceResponseNode) {
		this.invoiceResponse = objectMapper.convertValue(invoiceResponseNode, InvoiceResponse.class);
	}
```

I think in your case it would result in something like:

```
public void setValue(JsonNode processDataNode, Execution execution) {
		ProcessData processData = objectMapper.convertValue(processDataNode, ProcessData.class);
                processData.getAdresses().add(...);
                // TODO: Convert the processData back to JsonNode and put it to process variable map for update
	}
```

If there is a better solution, I would also be interested.

Cheers  
Martin

---

<div class="post-metadata">

**Author:** ![roman-mkh](https://avatars.discourse-cdn.com/v4/letter/r/7ba0ec/32.png) [@roman-mkh](https://forum.flowable.org/u/roman-mkh)\
**Post date:** [January 9, 2019, 11:31am UTC](https://forum.flowable.org/t/json-structure-and-expression-as-output-parameter/3193/3 "2019-01-09T11:31:56Z")

</div>

thank You, Martin. I came to the similar conclusion/solution.
