Forum Discussion
If you’re really concerned about performance, you might want to split the $fields
property in an upstream snap. Otherwise, it will be split for every property in the object when it is done in the filter() callback function, like here:
$.filter((value, key) => ($fields.split(',')).indexOf(key) >= 0)
(Really, the compiler should figure this out optimize away, but that’s not done right now.)
The [*]
syntax is for JSON-Paths and is not usable in the expression language, which is why this won’t work:
$input[*].filter((value, key) => ($fields.split(’,’)).indexOf(key) >= 0)
Instead, you’ll need to use the map() method to transform the elements of the $input
array. So, something like:
$input.map(x => x.filter((value, key) => ($fields.split(’,’)).indexOf(key) >= 0))
- j_angelevski4 years agoContributor III
Hi @SL12345,
Just use a JSON Splitter and split on
$CarDetails
array, but make sure you have enabled “Include scalar parents” option in the JSON Splitter.Result:
thank you, that is really what i wanted 🙂 and is it possible to wrap this content into object so from this:
{ "CompanyName": "TestCompany", "CompanyAddress": "TestAddress", "Brand": "BMW", "Year": "2020", "Fuel": "Petrol" } , { "CompanyName": "TestCompany", "CompanyAddress": "TestAddress", "Brand": "Jaguar", "Year": "2020", "Fuel": "Diesel" }
create this? Adding “Cars” as header or envelope for body/content?
{ "Cars": { "CompanyName": "TestCompany", "CompanyAddress": "TestAddress", "Brand": "BMW", "Year": "2020", "Fuel": "Petrol" } , { "CompanyName": "TestCompany", "CompanyAddress": "TestAddress", "Brand": "Jaguar", "Year": "2020", "Fuel": "Diesel" } }
- JensDeveloper4 years agoContributor II
Hi @SL12345 ,
Have you tried putting a groupByN snap behind it and as target field $Cars.
Regards
Jens
Related Content
- 3 months ago
- 3 years ago
- 5 years ago