Filter JSON records through a Task

Hello,

I would appreciate any help.

We are trying to create a task responsible for filtering the input data and making the filtered data available to the next tasks as an output parameter. I’m using the following script to do that, but the error “SPIN/JACKSON-JSON-01001 Unable to parse input into json node” occur.

var jsonString = originalData.jsonPath("$..products[?(@.productCategoryId == 228)]").toString();
var newJson = S('{ "response" : [{ "filteredProducts" : ' + jsonString + ' }] }');
newJson.prop("response").elements().get(0);

Does anybody have an idea on how to do this kind of operation or another suggestion/best practice to accomplish that?

Thanks in advance.

Sincerely,
André

Can you share a example of the full jsonString object?

Trying wrapping your value that is inside of the ‘s()’ with JSON.stringify()