AnsweredAssumed Answered

Freemarker loop through JSON object

Question asked by mikepoole on Sep 14, 2012
Latest reply on Aug 10, 2015 by chandrareddy
I have a webscript that is as follows:
var jsonRes = remote.call("/employeelist");
var result = eval('(' + jsonRes + ')');
model.employeelist = result;

This webscript returns a JSON object as shown in the example below

Example:

{ "employees": [
{ "name": "Fred Bloggs", "email": "fred@test.com", "id": "123456" } ,
{ "name": "John Smith", "email": "john@test.com", "id": "456789" } ,
{ "name": "Bob Brown", "email": "bob@test.com", "id": "987654" }  ] }

How can my Freemarker code loop through so that I can display the following…

Fred Bloggs : fred@test.com
John Smith : john@test.com
Bob Brown : bob@test.com

When I use

<#list journallist?keys as prop>
${prop}
</#list>

it returns

"employees"


Many thanks

Mike

Outcomes