{"ScriptPreparationCode":"var get = p =\u003E o =\u003E\r\n p.reduce((xs, x) =\u003E {\r\n \tif (Array.isArray(xs)) {\r\n \treturn xs.map(get([x])).filter(y =\u003E y !== null).flat();\r\n } else {\r\n \t \treturn (xs \u0026\u0026 xs[x]) ? xs[x] : null;\r\n }\r\n }, o);\r\n\r\nfunction flattenCollection(collectionIndex) {\r\n\tif (collectionIndex.type === \u0027imin:CollectionIndex\u0027) {\r\n return Object.entries(collectionIndex[\u0027imin:index\u0027]).reduce(function(map, [k,v]) {\r\n map[k] = flattenCollection(v);\r\n return map;\r\n }, {});\r\n } else if (collectionIndex.type === \u0027imin:Collection\u0027) {\r\n \treturn collectionIndex[\u0027imin:item\u0027].reduce(function(map, item) {\r\n map[item.id] = item;\r\n return map;\r\n }, {});\r\n } else {\r\n \treturn collectionIndex;\r\n }\r\n}","TestCases":[{"Name":"jsonata","Code":"var jsonataResult = jsonata(\u0027subEvent.offers.acceptedPaymentMethod\u0027).evaluate(result).join(\u0027\u003Cbr /\u003E\u0027);","IsDeferred":false},{"Name":"simple","Code":"var simpleResult = get([\u0027subEvent\u0027,\u0027offers\u0027,\u0027acceptedPaymentMethod\u0027])(result).join(\u0027\u003Cbr /\u003E\u0027);","IsDeferred":false},{"Name":"jspath","Code":"var jsPathResult = JSPath.apply(\u0027.subEvent.offers.acceptedPaymentMethod\u0027, result).join(\u0027\u003Cbr /\u003E\u0027);","IsDeferred":false},{"Name":"jmespath","Code":"var jmespathResult = jmespath.search(result, \u0027subEvent[].offers[].acceptedPaymentMethod[]\u0027).join(\u0027\u003Cbr /\u003E\u0027);","IsDeferred":false},{"Name":"control","Code":"result.subEvent.map(s =\u003E s.offers.map(o =\u003E o.acceptedPaymentMethod)).flat(2).join(\u0027\u003Cbr /\u003E\u0027)","IsDeferred":false},{"Name":"jspath\u002Bpredicates","Code":"var jsPathResult = JSPath.apply(\u0027.\u0022imin:aggregateOffer\u0022.publicAdult{.price \u003E 0 \u0026\u0026 .priceCurrency \u003E \u0022.\u0022}[-1]\u0027, result);","IsDeferred":false},{"Name":"meta-index","Code":"var jsPathResult = JSPath.apply(\u0027.\u0022imin:index\u0022(.subClass | .enumeration)..\u0022imin:item\u0022\u0027, window.imin.v2.meta);","IsDeferred":false},{"Name":"meta-nameonly","Code":"var jsPathResult = JSPath.apply(\u0027.\u0022imin:index\u0022(.subClass | .enumeration)..name\u0027, window.imin.v2.meta);","IsDeferred":false},{"Name":"meta-flatten","Code":"var result = flattenCollection(window.imin.v2.meta);","IsDeferred":false}]}