# Array or JSON Object Process Variable

**URL:** https://forum.flowable.org/t/array-or-json-object-process-variable/548
**Category:** Flowable Engine
**Created:** [May 10, 2017, 2:46pm UTC](https://forum.flowable.org/t/array-or-json-object-process-variable/548 "2017-05-10T14:46:59Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jaimerivera](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@jaimerivera](https://forum.flowable.org/u/jaimerivera)
#### Post date: [May 10, 2017, 2:46pm UTC](https://forum.flowable.org/t/array-or-json-object-process-variable/548/1 "2017-05-10T14:46:59Z")

</div>

It seems the engine is not allowing me to save arrays and json objects to the process using execution.setVariable

Doing the following results in an error:

var t = [5, 6];  
execution.setVariable(“values”, t);

---

<div class="post-metadata">

### Author: ![martin.grofcik](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/martin.grofcik/32/71_2.png) [@martin.grofcik](https://forum.flowable.org/u/martin.grofcik)
#### Post date: [May 11, 2017, 6:25am UTC](https://forum.flowable.org/t/array-or-json-object-process-variable/548/2 "2017-05-11T06:25:27Z")

</div>

Hi,

the exception says:

```
org.flowable.engine.common.api.FlowableException: couldn't find a variable type that is able to serialize [object Array]
	at org.flowable.engine.impl.variable.DefaultVariableTypes.findVariableType(DefaultVariableTypes.java:62)
	at org.flowable.engine.impl.persistence.entity.VariableScopeImpl.createVariableInstance(VariableScopeImpl.java:863)
	at org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl.createVariableInstance(ExecutionEntityImpl.java:531)
	at org.flowable.engine.impl.persistence.entity.VariableScopeImpl.createVariableLocal(VariableScopeImpl.java:784)
	at org.flowable.engine.impl.persistence.entity.VariableScopeImpl.setVariable(VariableScopeImpl.java:662)
	at org.flowable.engine.impl.persistence.entity.VariableScopeImpl.setVariable(VariableScopeImpl.java:654)

```

You can easily add new type support in ProcessEngineConfiguration.  
See `org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl#initVariableTypes`

```
public void initVariableTypes() {
    if (variableTypes == null) {
        variableTypes = new DefaultVariableTypes();
        if (customPreVariableTypes != null) {
            for (VariableType customVariableType : customPreVariableTypes) {
                variableTypes.addType(customVariableType);
            }
        }
        variableTypes.addType(new NullType());
        variableTypes.addType(new StringType(getMaxLengthString()));
        variableTypes.addType(new LongStringType(getMaxLengthString() + 1));

```

The example in the jUnit test is `org.flowable.examples.variables.VariablesTest#testBasicVariableOperations`

Regards  
Martin

---

<div class="post-metadata">

### Author: ![boneill](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/boneill/32/896_2.png) [@boneill](https://forum.flowable.org/u/boneill)
#### Post date: [November 2, 2018, 11:51am UTC](https://forum.flowable.org/t/array-or-json-object-process-variable/548/3 "2018-11-02T11:51:22Z")

</div>

> [@martin.grofcik](#):
>
> testBasicVariableOperations

Hi Martin,

What is the method for doing this in flowable 6. ProcessEngineConfiguration does not have any methods for setting variable types.

Regards

Brian

---

<div class="post-metadata">

### Author: ![boneill](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/boneill/32/896_2.png) [@boneill](https://forum.flowable.org/u/boneill)
#### Post date: [November 4, 2018, 11:22am UTC](https://forum.flowable.org/t/array-or-json-object-process-variable/548/4 "2018-11-04T11:22:43Z")

</div>

Got it to work by injecting my type into config. See below. Is there a reason that there is no method on the ProcessEngineConfiguration interface. Not sure why I needed to use the Impl class:

ProcessEngineConfiguration cfg = new StandaloneProcessEngineConfiguration()  
.setJdbcUrl(“jdbc:h2:mem:flowable;DB\_CLOSE\_DELAY=-1”)  
.setJdbcUsername(“sa”)  
.setJdbcPassword("")  
.setJdbcDriver(“org.h2.Driver”)  
.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB\_SCHEMA\_UPDATE\_TRUE);

```
	//cfg.getDef	
		
  ProcessEngineConfigurationImpl processEngineConfig = (ProcessEngineConfigurationImpl)cfg;
  processEngineConfig.initVariableTypes();
  processEngineConfig.getVariableTypes().addType(new CustomObjectType("camelbody", CamelBody.class));

  ProcessEngine processEngine = processEngineConfig.buildProcessEngine();
```

---

<div class="post-metadata">

### Author: ![filiphr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/filiphr/32/315_2.png) [@filiphr](https://forum.flowable.org/u/filiphr)
#### Post date: [November 5, 2018, 7:09am UTC](https://forum.flowable.org/t/array-or-json-object-process-variable/548/5 "2018-11-05T07:09:11Z")

</div>

@boneill you If you use an instance of the `StandaloneProcessEngineConfiguration` then you would get access to it. On top of that I would advise against doing what you are doing? calling `initVariableTypes` and then adding to it.

Instead I would do:

```auto
ProcessEngineConfiguration cfg = new StandaloneProcessEngineConfiguration()
.setJdbcUrl(“jdbc:h2:mem:flowable;DB_CLOSE_DELAY=-1”)
.setJdbcUsername(“sa”)
.setJdbcPassword("")
.setJdbcDriver(“org.h2.Driver”)
.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE)
.setCustomPostVariableTypes(Arrays.asList(new CustomObjectType("camelbody", CamelBody.class)));

ProcessEngine processEngine = processEngineConfig.buildProcessEngine();

```

Cheers,  
Filip
