# Creating decision table from json in java and deploying it

**URL:** <https://forum.flowable.org/t/creating-decision-table-from-json-in-java-and-deploying-it/6875>\
**Category:** Flowable Engine\
**Created:** [October 6, 2020, 6:32am UTC](https://forum.flowable.org/t/creating-decision-table-from-json-in-java-and-deploying-it/6875 "2020-10-06T06:32:10Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![madhuvardan-CMI](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@madhuvardan-CMI](https://forum.flowable.org/u/madhuvardan-CMI)\
**Post date:** [October 6, 2020, 6:32am UTC](https://forum.flowable.org/t/creating-decision-table-from-json-in-java-and-deploying-it/6875/1 "2020-10-06T06:32:10Z")

</div>

I have created decision table in java using Decision Table (dmn.model.DecisionTable). But couldn’t figure out how to convert this decision table to xml (.dmn) or inputstream so that it can be deployed with dmnRepositoryService. Can you help on how to achieve this?

---

<div class="post-metadata">

**Author:** ![yvo](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/yvo/32/2231_2.png) [@yvo](https://forum.flowable.org/u/yvo)\
**Post date:** [October 6, 2020, 8:37am UTC](https://forum.flowable.org/t/creating-decision-table-from-json-in-java-and-deploying-it/6875/2 "2020-10-06T08:37:46Z")

</div>

Hi,

If you want to create the model programmatically you need to create a `DmnDefinition`.  
You can then deploy that directly using the dmnRepositoryService;

```auto
repositoryService.createDeployment()
    .name("Deployment of DMN definition")
    .addDmnModel(dmnDefinition)
    .deploy();

```

Hope this helps.

Regards,

Yvo

---

<div class="post-metadata">

**Author:** ![madhuvardan-CMI](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@madhuvardan-CMI](https://forum.flowable.org/u/madhuvardan-CMI)\
**Post date:** [October 6, 2020, 9:15am UTC](https://forum.flowable.org/t/creating-decision-table-from-json-in-java-and-deploying-it/6875/3 "2020-10-06T09:15:56Z")

</div>

Hi,

But how to add the decision table to dmnDefinition ?

Regards,

Madhu

---

<div class="post-metadata">

**Author:** ![yvo](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/yvo/32/2231_2.png) [@yvo](https://forum.flowable.org/u/yvo)\
**Post date:** [October 6, 2020, 9:22am UTC](https://forum.flowable.org/t/creating-decision-table-from-json-in-java-and-deploying-it/6875/4 "2020-10-06T09:22:25Z")

</div>

I assume that when you’re creating a DecisionTable in Java you have knowledge of the DMN Model.  
Otherwise I suggest you use the Decision Table editor in Flowable Modeler to create the table and export it to DMN (model) XML. You can use that to deploy it to the engine.

Regards,

Yvo

---

<div class="post-metadata">

**Author:** ![madhuvardan-CMI](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@madhuvardan-CMI](https://forum.flowable.org/u/madhuvardan-CMI)\
**Post date:** [October 6, 2020, 9:44am UTC](https://forum.flowable.org/t/creating-decision-table-from-json-in-java-and-deploying-it/6875/5 "2020-10-06T09:44:55Z")

</div>

Hi,

What i was trying to achieve is, handling creating the decision table in the UI and saving that table as json in DB. When there are any new decision table created I will get JSON and create decision table in the backend and try to deploy it. I have tried to create dmnDefinition using DmnXMLConverter().convertToDmnModel() but it asking for inputstreamprovider or XMLstreamReader as an input. I have no idea on how to pass decision table here.

Regards,  
Madhu

---

<div class="post-metadata">

**Author:** ![yvo](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/yvo/32/2231_2.png) [@yvo](https://forum.flowable.org/u/yvo)\
**Post date:** [October 6, 2020, 9:57am UTC](https://forum.flowable.org/t/creating-decision-table-from-json-in-java-and-deploying-it/6875/6 "2020-10-06T09:57:22Z")

</div>

When you have the editor JSON you can convert that DMN model using the `DmnJsonConverter`

`DmnDefinition DmnJsonConverter.convertToDmn(JsonNode modelNode)`

You can then deploy the DMN model.  
The DmnJsonConverter is for converting between DMN model (/DmnDefinition) and editor JSON model.  
The DmnXMLConverter is for converting between DMN XML en DMN model

Perhaps looking at some unit test code for these 2 projects will help you on how to use these apis.

Yvo

---

<div class="post-metadata">

**Author:** ![madhuvardan-CMI](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@madhuvardan-CMI](https://forum.flowable.org/u/madhuvardan-CMI)\
**Post date:** [October 6, 2020, 10:20am UTC](https://forum.flowable.org/t/creating-decision-table-from-json-in-java-and-deploying-it/6875/7 "2020-10-06T10:20:57Z")

</div>

Hi,  
Thanks for the suggestion, is there a proper format for the JsonNode which it accepts?

Thanks,  
Madhu

---

<div class="post-metadata">

**Author:** ![yvo](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/yvo/32/2231_2.png) [@yvo](https://forum.flowable.org/u/yvo)\
**Post date:** [October 6, 2020, 10:36am UTC](https://forum.flowable.org/t/creating-decision-table-from-json-in-java-and-deploying-it/6875/8 "2020-10-06T10:36:35Z")

</div>

Not sure I understand your question correctly; but the JsonNode represents the JSON structure of the decision table in the decision table editor in Flowable Modeler.  
For example;

> <https://github.com/flowable/flowable-engine/blob/master/modules/flowable-dmn-json-converter/src/test/resources/org/flowable/dmn/editor/converter/decisiontable_1.json>

Regards,

Yvo

---

<div class="post-metadata">

**Author:** ![madhuvardan-CMI](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@madhuvardan-CMI](https://forum.flowable.org/u/madhuvardan-CMI)\
**Post date:** [October 6, 2020, 11:29am UTC](https://forum.flowable.org/t/creating-decision-table-from-json-in-java-and-deploying-it/6875/9 "2020-10-06T11:29:35Z")

</div>

Hi Yvo,

Thanks for the help, this works fine

Regards,  
Madhu
