What is the best way to assign a datetime attribute from a JSON variable into a datetime variable of my process?

Hi all,

In my process, I have a JSON variable “myJsonVar” containing different attributes. One of these attributes is a date:

{
  "content": {
    "info": {
      "id_d": "QALOms2",
      "type": "xxxxxxxx",
      "titre": "yyyyyyyyyyy",
      "creation": "2021-10-08 15:39:03",
      "modification": "2021-10-08 16:05:51"
    },
  "data": {
  }
}

There is no specific type for date in JSON, a date is a simple string. So I can’t assign this JSON date to a variable with a type ‘date’ in my process:

<callActivity id="dsfsdf" name="Control" calledElement="myControl">
   <extensionElements>
      <flowable:in sourceExpression="${myJsonVar.date}" target="date"/>
      ...
   </extensionElements>
</callActivity>

It is needed to convert it.

What is the best way to do this conversion ?:

  • a script task just before the assignment can be used to convert the JSON date, but this adds a technical task in my business process. It’s not satisfying,
  • add a new custom JUEL function to parse a JSON date into java.util.Date, and so the result of this function can be assign to a date variable: <flowable:in sourceExpression="${date:parse(myJsonVar.date)}" target="date"/>
  • another way.

If the best solution is to use a new custom JUEL function, is it interesting to put this function in Flowable engine to be usable by all of us ? I’m ready to do this contribution.

Thanks for your help

Hi all,

Has anyone had to deal with this kind of problem? How did you do ?

Thanks a lot for your help

We add a script task just before the assignment to convert the JSON date

Hi all,

When starting to write my own custom JUEL function to pare a JSON date, I discover that similar reverse custom JUEL functions exist in DMN engine, but only in DMN engine. IMO, it should be common for all. No ?

Regards
Christophe

1 Like