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