Forum Discussion

pp_01's avatar
pp_01
Mentor
7 years ago

Reordering a nested JSON in freemarker.

Hey guys. Is there any way so that a nested JSON response can be reordered? I want to rearrange the position of objects from the way I'm getting to a different manner. Suppose my JSON and my requirem...
  • TariqHussain's avatar
    7 years ago

    pp_01 Yes, you can achieve this. 

     

    e.g  You have stored all the json inside a variable. You need keys and reverse function to achieve the result. 

    <#assign json = {//your json here} /> 
    <#list json?keys?reverse as key> ${key} - ${json[key]} </#list>