0

I need to iterate over this map in freemarker language.

public static void main(String[] args) {
       Map<String, Map<String, Map<String,String>>> map = new HashMap<>();
}

on the basis of each string i need to get map then again on the basis of string again map is needed. thanks

Ravi
  • 30,829
  • 42
  • 119
  • 173
devtest
  • 89
  • 1
  • 8
  • If this is Java, you can use `Map.entrySet`. [Reference](https://stackoverflow.com/questions/46898/how-to-efficiently-iterate-over-each-entry-in-a-map). – user202729 Jan 07 '18 at 13:06
  • if you're using java-8 then `map.forEach((k, v) -> { .... v.forEach((e, a) -> { .... a.forEach((b, c) -> { ... }); }); });` would suffice – Ousmane D. Jan 07 '18 at 13:19
  • thanks for your answers but i need to implement iteration in freemarker – devtest Jan 07 '18 at 13:35
  • @devtest I'm not sure about freemaker, but are you saying none of below answer works for you ?? If yes, then you must check, if you are really working on Java – Ravi Jan 07 '18 at 13:46
  • @Ravi thanks for your answer, in java i can do but i need to iterate it in freemarker – devtest Jan 07 '18 at 14:55
  • 1
    @devtest Then it is not java. please select the tag correctly. I have removed anyway – Ravi Jan 07 '18 at 16:38

1 Answers1

1

It seems there is three level nested map, you can drill down using list and you can show both key and value

Listing hashes is very similar, but you need to provide two variable names after the as; one for the hash key, and another for the associated value.

<#list map?values as vals>
  <#list vals?values  as innervals>
    <#list innervals as name, innerValue>
      ${name} value = ${innerValue}
    </#list>
  </#list>
</#list>
Ori Marko
  • 56,308
  • 23
  • 131
  • 233