# Flowable transforming JSON/Serializable variables

**URL:** <https://forum.flowable.org/t/flowable-transforming-json-serializable-variables/6201>\
**Category:** Flowable Engine\
**Created:** [June 11, 2020, 11:23pm UTC](https://forum.flowable.org/t/flowable-transforming-json-serializable-variables/6201 "2020-06-11T23:23:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Catalyst344](https://avatars.discourse-cdn.com/v4/letter/c/90ced4/32.png) [@Catalyst344](https://forum.flowable.org/u/Catalyst344)\
**Post date:** [June 11, 2020, 11:23pm UTC](https://forum.flowable.org/t/flowable-transforming-json-serializable-variables/6201/1 "2020-06-11T23:23:32Z")

</div>

Hi all,

I have a process where I execute an HTTP task that uses a variable as the JSON body.

I just wanted to note that I’m only using the REST API for this.

When I start my process, I submit my variables. This is the variable array:

```
 [{"name":"myJSONBody","value":{"first_field":"1","second_field":"2","last_field":"Hello World"}}]

```

As you can see, the variable is of type JSON and when I look up my variables I can see that it’s categorized as serializable:

```
{
    "name": "myJSONBody",
    "type": "serializable",
    "value": null,
    "valueUrl": "http://myurl/process-api/runtime/tasks/my-task-id/variables/myJSONBody/data",
    "scope": "global"
  }

```

Later on in the process, I use this variable for an HTTP task. The request body is like this:

```
{
"test_var": "${myJSONBody}"
}

```

Unfortunately, the JSON object from the variable **myJSONBody** now looks like this:

`{first_field=1, second_field=2, last_field=Hello World}`

Does anyone know why my JSON object gets transformed from this format:

`"key": "value"`

To this?

`key=value`

Is there any way to store my JSON object in a variable exactly as is without it being modified? If not, is there a function I can call in the HTTP Task request body that would convert this to be in the exact same format before? I’m trying to understand this behavior of why this is happening. As you can imagine, when this call is made, the body being submitted is incorrectly formatted and the API can’t understand the request body.

I tried reading some documentation from the link below, but it doesn’t go too far in depth of how serializable variables function:

[https://flowable.com/open-source/docs/bpmn/ch15-REST/](https://flowable.com/open-source/docs/bpmn/ch15-REST/)

Is it possible for me to have my variable be saved in the following format?

```
{"first_field":"1","second_field":"2","last_field":"Hello World"}

```

Any help would be greatly appreciated. Thank you guys in advance!

---

<div class="post-metadata">

**Author:** ![nickthearchitect](https://avatars.discourse-cdn.com/v4/letter/n/c68b51/32.png) [@nickthearchitect](https://forum.flowable.org/u/nickthearchitect)\
**Post date:** [June 12, 2020, 4:41pm UTC](https://forum.flowable.org/t/flowable-transforming-json-serializable-variables/6201/2 "2020-06-12T16:41:36Z")

</div>

> [@Catalyst344](#):
>
> ```auto
> {
> "name": "myJSONBody",
> "type": "serializable",
> "value": null,
> "valueUrl": "http://myurl/process-api/runtime/tasks/my-task-id/variables/myJSONBody/data",
> "scope": "global"
> }
> 
> ```

I think if your variable really was JSON, the type would be “json”, not “serializable”. Serializable is typically for Java objects, including Maps and Lists.  
I think your variable definition at the start isn’t defining the type, so I think it may be defaulting to string (from memory). Can you try setting the type explicitly to json? Something like this, maybe:

> [{“name”:“myJSONBody” **,“type”:“json”** ,“value”:{“first\_field”:“1”,“second\_field”:“2”,“last\_field”:“Hello World”}}]

---

<div class="post-metadata">

**Author:** ![Catalyst344](https://avatars.discourse-cdn.com/v4/letter/c/90ced4/32.png) [@Catalyst344](https://forum.flowable.org/u/Catalyst344)\
**Post date:** [June 12, 2020, 5:18pm UTC](https://forum.flowable.org/t/flowable-transforming-json-serializable-variables/6201/3 "2020-06-12T17:18:49Z")

</div>

Looks like this was exactly it! I had to specify explicitly set it to JSON.

Thank you so much!

---

<div class="post-metadata">

**Author:** ![Varriount](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/varriount/32/1139_2.png) [@Varriount](https://forum.flowable.org/u/Varriount)\
**Post date:** [June 15, 2020, 2:36am UTC](https://forum.flowable.org/t/flowable-transforming-json-serializable-variables/6201/4 "2020-06-15T02:36:46Z")

</div>

@Catalyst344 So Flowable supports “JSON” as a variable type, despite the documentation not stating it as a supported type?

---

<div class="post-metadata">

**Author:** ![Catalyst344](https://avatars.discourse-cdn.com/v4/letter/c/90ced4/32.png) [@Catalyst344](https://forum.flowable.org/u/Catalyst344)\
**Post date:** [June 17, 2020, 2:18pm UTC](https://forum.flowable.org/t/flowable-transforming-json-serializable-variables/6201/5 "2020-06-17T14:18:57Z")

</div>

@Varriount Seems that way. I haven’t attempted to use “JSON” because I didn’t know it was an option. I assumed all JSON gets treated as serializable.

---

<div class="post-metadata">

**Author:** ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)\
**Post date:** [June 28, 2020, 9:15am UTC](https://forum.flowable.org/t/flowable-transforming-json-serializable-variables/6201/6 "2020-06-28T09:15:52Z")

</div>

> [@Varriount](#):
>
> despite the documentation not stating it as a supported type

Can you point to the documentation where we state it’s not supported, then we can fix it?

> [@Catalyst344](#):
>
> I haven’t attempted to use “JSON” because I didn’t know it was an option. I assumed all JSON gets treated as serializable.

If you use JsonNode/ObjectNode (on the Java level), it will be stored properly (which is what REST seems to use). All current possible types are here: [flowable-engine/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/types at main · flowable/flowable-engine · GitHub](https://github.com/flowable/flowable-engine/tree/master/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/types) (including JsonType).

---

<div class="post-metadata">

**Author:** ![dragan\_torbica](https://avatars.discourse-cdn.com/v4/letter/d/47e85d/32.png) [@dragan\_torbica](https://forum.flowable.org/u/dragan_torbica)\
**Post date:** [July 16, 2021, 1:10pm UTC](https://forum.flowable.org/t/flowable-transforming-json-serializable-variables/6201/7 "2021-07-16T13:10:02Z")

</div>

Hi @joram

I believe that Varriount thinks of this part of documentation:

> **[REST API · Flowable Open Source Documentation](https://flowable.com/open-source/docs/bpmn/ch15-REST/#request-parameters)**
>
> \## General Flowable REST principles

(and then Variable representation → Variable types)

After reading it, I had impression that only those seven types (string, short, integer, long, double, boolean, date) are supported by Flowable, and that all other have to implemented according to project needs. However, after looking at impl/types folder, I saw that for instance JsonType is implemented (just the thing I need at the moment).

Documentation is correct if we observe it from perspective of modeler and demo-client (these are the the types that one can model in forms and what will be shown in democlient) but it was not clear to me that engine can already do a bit more.

Hope this helps!  
Dragan

edit: corrected the link. the first one was from DMN User guide

---

<div class="post-metadata">

**Author:** ![Jolley71717](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/jolley71717/32/3528_2.png) [@Jolley71717](https://forum.flowable.org/u/Jolley71717)\
**Post date:** [July 12, 2024, 4:19pm UTC](https://forum.flowable.org/t/flowable-transforming-json-serializable-variables/6201/8 "2024-07-12T16:19:22Z")

</div>

> [@joram](#):
>
> where we state it’s not supported, then we c

If you are passing variables in using the flowable.dmn.api.DmnDecisionService, is it possible to specify the type? They appear to be automatically set as String rather than serializable or Json, so the values saved in the database are the `Object(this=that)` style.

```auto
dmnDecisionService
            .createExecuteDecisionBuilder()
            .decisionKey(decisionKey)
            .variable("data", input)
            .variable("requestId", requestId)
            .executeDecisionServiceWithAuditTrail()

```
