My problem is as follows. I get a JSON string from an api call which looks like that:
I always want to know the timestamp at which the package has been picked up by a courier.
The essential problem here is that the pickup is not always the same number in the "events" branch of the string. But the "code" is always 3.0 or something. It would be not a problem if the "events" are always at the same place. Then I could do something, its just an example, like this:
<#assign someParsed = responseContent?eval_json>
${someParsed.parcels[0].events[0].timestamp}
So how do I get the bottom line of the code if the position is not always at the same position?
Assuming there's always a code 3.0
(otherwise of course you need to test for that), you can do it like this:
${someParsed.parcels[0].events?filter(it -> it.code == '3.0')[0].timestamp}