Forum Discussion
I think the issue is that I have to use ?eval to convert it into ftl hash, but when I try using ?eval, it is still giving an error.
Can you suggest, where do I put ?eval so that I can iterate through the FTL hash using list
<#assign search_query = http.request.parameters.name.get("search_query","optimizely") />
<#assign response = http.client.request("http://community/collection1/select?q=${search_query}&wt=json&indent=true").json()/>
<#if response.hasError>
${response.error.message}
<#else>
${response.content}
</#if>
Hi Gursimrat
I haven't tried it myself to be honest but looking at some internal documentation it seems that you're right, ?eval should parse a JSON string into a FTL hashmap.
You should be doing something like this:
<#assign search_query = http.request.parameters.name.get("search_query","optimizely") /> <#assign response = http.client.request("http://community/collection1/select?q=${search_query}&wt=json&indent=true").get()/> <#if response.hasError> ${response.error.message} <#else> <#assign theHash = ${response.content?eval} ${theHash.response.docs[0].summary} </#if>
Please let me know if this works.
Thanks,
Nico
Related Content
- 10 years ago
- 6 years ago