Closed yvrng closed 7 months ago
I'm afraid this is not as simple as it seems as our ObjectMapper is shared by all plugins and we don't want to add the Groovy library to all of them so we can't add a Jackson module that depends on Groovy.
By the way, you wan easily make it works by calling toString()
by yourself:
id: bad-serdes
namespace: myteam
tasks:
- id: transform
type: io.kestra.plugin.scripts.groovy.FileTransform
from: >
[{"value":"awesome"}]
script: >
row["value"] = "Kestra is ${row.value}!".toString()
Thanks Loïc, I understand you don't want to include Groovy globally.
We applied your solution, it works fine.
Expected Behavior
I use a lot of Groovy scripts to transform datasets.
To give a little context: in Groovy, when we use string substitution, like
"${key} ${value}"
, it creates an instance ofGString
(it's notString
). Unfortunately, these instances are not properly serialized when written in ION files.For example, if I have this script:
When serialized in ION, I would like to have this result:
Actual Behaviour
But, I find:
The
GString
object is serialized as a POJO, instead of calling its representation withtoString()
For other needs, I created this Jackson module, registrable
mapper.registerModule(new GroovyModule())
:Steps To Reproduce
No response
Environment Information
Example flow