JSON data source - relative attribute - 2nd last item in array

(Erwin Strobel) #1

[Squiz Matrix v5.5.0.2]


I have a JSON data source, populated from an asset listing.

Within the “JSON Data Attributes” field on the details screen, I am trying to set up a new relative attribute, I have it working if I target a value from the start of the array e.g. (myAttribute[0]), however I need to target the 2nd last value in the array, which I can’t seem to find a way of doing).

Basically trying to achieve something like this:
myAttribute[myAttribute.length - 2]

Anyone know if this is possible?

(Bart Banda) #2

Hi Erwin, I don’t think it’s possible.

You could do that kind of filtering using Server Side JS perhaps if you grab all of the data of this JSON data via a REST asset instead perhaps and do some JS massaging in there?

(Erwin Strobel) #3

Thanks Bart,

A server side js solution which did the trick!.