I have EventBus, which has a rule with certain target. There is an InputTransformer inside the target with the InputPath and InputTemplate. I want the transformation to the Array as a result.
I send custom event to EventBus with the detail field, in which I have desired JSON
{
"version": "0",
"id": "9fd93571-3201-4e0d-6cf0-328ff344c9e3",
"detail-type": "test",
"source": "foobar",
"account": "192675374686",
"time": "2023-10-10T11:22:01Z",
"region": "us-east-1",
"resources": [],
"detail": {
"address": {
"field": "888",
"innerField": {
"someInnerField": "999"
}
}
}
}
My expected output is the Array, when I try this InputPath and InputTemplate adding the square brackets, it sends it without double quotes, but it does some transformation.
InputPath
{
"detail": "$.detail"
}
InputTemplate
[{
"customField": <detail>
}]
Actual Output (Message taken from dead-letter queue which configured with target, it was send there, because of invalid json, which is true)
[{
"customField": {address:{field:888,innerField:{someInnerField:999}}}
}]
Expected Output
[{
"customField": {
"address": {
"field": "888",
"innerField": {
"someInnerField": "999"
}
}
}
}]
What will totally work, but it doesn't work for JSON with a lot of fields
Sure, we can map every field inside InputPath and then put it inside the template via variables. Already checked it, works.
Path
{
"field": "$.detail.address.field",
"someInnerField": "$.detail.address.innerField.someInnerField"
}
Template
[{
"customField": {
"address": {
"field": "<field>"
"innerField": {
"someInnerField": "<someInnerField>"
}
}
}
}]
Received an answer at stackoverflow - https://stackoverflow.com/a/77282222/12654113