'Get value from sequence Freemarker
I've got a call that gives a result in the body that looks like this: body=[{"id":"be6ea215-1a69-44bb-8269-4f80867c69d7","name":"BlaBla1","externalLinks":[]},{"id":"ac3d6f12-61fe-4b4c-8515-12bbb5155a56","name":"BlaBla2","externalLinks":[]},{"id":"e279d52a-e6b7-4f81-912b-a1a990509955","name":"BlaBla3","externalLinks":[]}]
From this data I need to retrieve the name that follows a specific Id, f.e. specificId="e279d52a-e6b7-4f81-912b-a1a990509955".
I tried to use filter, or map, or list, but whatever I do I get stuck in the variable types: the Id to check for doesn't match the data from the body (and the body can't be edited like a string). Is there any way to get a specific name from this list?
I get errors like this (using list): Left hand operand is an extended_hash (LinkedHashMap wrapped into f.t.DefaultMapAdapter). Right hand operand is an extended_hash+string (UUID wrapped into f.e.b.StringModel).
An example of what I tried (just one out of many, I obviously don't understand the variable type):
<#list (body)?replace(","externalLinks":[]","") as key, value> <#if key==specificId> <#assign indexId=key?index+1 nameIWant=body[indexId]> </#if> </#list>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
