Storing DMN in JSON format

326 views
Skip to first unread message

Ravi Mangalagiri

unread,
Apr 20, 2022, 10:43:20 PM4/20/22
to Kogito development mailing list
Hi Kogito Team,
Our requirement needs to persist DMN(s) in DocumentDB (AWS). And we would like to store it as json. The reason is to be able to query/filter dmn(s) based on 'itemDefinition' or 'itemComponent' or 'decisionName' and so on, just like DMN CLI

Is there a utility to convert dmn xml to json and viceversa.

The other option is to store dmn xml in dynomoDB (AWS) and have a few keys defined as index.


Any thoughts?
--
Ravi Mangalagiri

Jacopo Rota

unread,
Apr 21, 2022, 2:32:32 AM4/21/22
to kogito-de...@googlegroups.com
What about 

<dependency>  
    <groupId>org.json</groupId>  
    <artifactId>json</artifactId>  
    <version>20180130</version>  
</dependency>  

JSONObject json = XML.toJSONObject(xml);  
String jsonString = json.toString(); 

?   


--
You received this message because you are subscribed to the Google Groups "Kogito development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kogito-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kogito-development/CALg%3DC8NYySCcpkiXo9gfEKjhZ2y%2B2sw%2BjcBgnDTvVjDas8THoA%40mail.gmail.com.

Jacopo Rota

unread,
Apr 21, 2022, 2:36:46 AM4/21/22
to kogito-de...@googlegroups.com
Sorry I missed that you wanted to convert it back to xml then. Let me see if is there already something 

Jacopo Rota

unread,
Apr 21, 2022, 2:58:08 AM4/21/22
to kogito-de...@googlegroups.com
You can take a look at my snippet here https://pastebin.com/kDpYZUF1

There are libraries like https://github.com/javadev/underscore-java that can do the trick for you as they implemented some workarounds to deal with xml attributes. 

If you don't want to use that library directly for whatever reason, I guess it would not be that hard to implement the same logic. 

Best, 

Jacopo

Gabriele Cardosi

unread,
Apr 21, 2022, 4:03:49 AM4/21/22
to Kogito development mailing list
Hi Ravi,
another option could be Xstream: it has drivers for both XML and JSON and, if I'm not wrong, it was originally used for DMN, so there could also be some reusable code in some old version of our code base

M2C

Best

Gabriele



--

GABRIELE CARDOSI

SENIOR SOFTWARE ENGINEERS, MW

Red Hat Ltd

gcar...@redhat.com    M: +39-3461717132    

Gabriele Cardosi

unread,
Apr 21, 2022, 4:04:50 AM4/21/22
to Kogito development mailing list
Hi Ravi,
an option could be Xstream: it has drivers for both XML and JSON and, if I'm not wrong, it was originally used for DMN, so there could also be some reusable code in some old version of our code base

M2C

Best

Gabriele

On Thu, Apr 21, 2022 at 4:43 AM Ravi Mangalagiri <ravi.man...@gmail.com> wrote:
--
You received this message because you are subscribed to the Google Groups "Kogito development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kogito-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kogito-development/CALg%3DC8NYySCcpkiXo9gfEKjhZ2y%2B2sw%2BjcBgnDTvVjDas8THoA%40mail.gmail.com.


--

Ravi Mangalagiri

unread,
Apr 21, 2022, 9:30:22 AM4/21/22
to Kogito development mailing list
Let me work on that pointers and get back.
.

Thanks for that quick response

Ravi Mangalagiri

unread,
Apr 21, 2022, 9:54:07 AM4/21/22
to Kogito development mailing list
It worked.  https://github.com/javadev/underscore-java  did the magic

Thanks Guys! 
--
Ravi Mangalagiri

Matteo Mortari

unread,
Apr 21, 2022, 10:07:45 AM4/21/22
to Kogito development mailing list
Hi Ravi,
you could also consider making a write-up / blog post of the use-case, and share it with the Kogito community :) 

Additionally, you might consider submitting your use-case as a Practitioner paper to the Decision Camp conference, if you or a colleague could attend it: https://decisioncamp2022.wordpress.com/call-for-presentations

Ciao,
MM



--

Ravi Mangalagiri

unread,
Apr 21, 2022, 10:15:24 AM4/21/22
to Kogito development mailing list

subash k

unread,
Jun 7, 2022, 8:17:41 AM6/7/22
to Kogito development mailing list
Hi Ravi, 

we have Oracle SOA business rules and decision tables , now we are upgrading to oracle cloud integrations[OIC] - Process cloud Decision models.
As part of upgrade we have exported Oracle SOA business rules and decision tables to excel files and converted Excel files to DMN xml format .
oracle cloud integrations[OIC] - Process cloud  expecting/allowing  DMN in json .can you please provide the method or process to follow  convert DMN xml to DMN json.

Thanks in advance.
Subash

Ravi Mangalagiri

unread,
Jun 7, 2022, 8:34:18 AM6/7/22
to Kogito development mailing list
Hi Subash,
As I mentioned I used https://github.com/javadev/underscore-java  utility added to my POM and used U.xmlToJson()to convert dmn xml to json
  <dependency>
    <groupId>com.github.javadev</groupId>
    <artifactId>underscore</artifactId>
    <version>1.78</version>
  </dependency>




--
Ravi Mangalagiri
Reply all
Reply to author
Forward
0 new messages