When we have long-running json-formula sessions (as with forms), we often encounter complex expressions that are repeated later in the session.
For example, given an ISO8601 duration value such as: {"cookTime": "PT1H45M"}
The following expression will transform it to English text:
substitute(cookTime, 'PT', '') |
split(@, 'H') |
reduce(&accumulated & if (find('M', current),' ' & substitute(current, 'M', ' Minutes'), current & if (current != '1', ' hours', ' hour')), @)
We propose to add the ability to register such an expression as a function to allow the author to keep only one copy of the logic.
e.g.
Then for the remainder of the session, a duration can be displayed using:
duration(cookTime)
All registered functions may accept only one parameter -- referenced in the expression using the current context @. If more parameters are required, they can be combined in a map or array.
When we have long-running json-formula sessions (as with forms), we often encounter complex expressions that are repeated later in the session. For example, given an ISO8601 duration value such as:
{"cookTime": "PT1H45M"}
The following expression will transform it to English text:We propose to add the ability to register such an expression as a function to allow the author to keep only one copy of the logic. e.g.
Then for the remainder of the session, a duration can be displayed using:
duration(cookTime)
All registered functions may accept only one parameter -- referenced in the expression using the current context
@
. If more parameters are required, they can be combined in a map or array.