I have a Map with a key and value as linked List as shown below
{Ice creams=[Cone,KoolCool(21), Stick,KoolCool(25)]}
With this i need to construct a following json
{
    "name": "Ice creams",
    "T2": [
        {
            "name": "Cone",
            "T3": [
                {
                    "name": "KoolCool",
                    "leaf": []
                }
            ]
        },
        {
            "name": "Stick",
            "T3": [
                {
                    "name": "KoolCool",
                    "leaf": []
                }
            ]
        }
    ]
}
Every comma seperated value will increment the T value
I am trying to apprach this with the below
- For every key in the Map Access its value as LinkedList
- From that LinkedList access split it and construct the json
Could anybody please let me know if there is a better way of doing this ??
package com.util;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Map;
public class Test {
    public static void main(String args[]) {
        Map<String, LinkedList<String>> consilatedMapMap = new LinkedHashMap<String, LinkedList<String>>();
        LinkedList<String> values = new LinkedList<String>();
        values.add("Cone,KoolCool(21)");
        values.add("Stick,KoolCool(25)");
        consilatedMapMap.put("Ice creams", values);
        /*
         * for (Map.Entry<String, LinkedList<String>> consilMap :
         * consilatedMapMap.entrySet()) {
         * 
         * String t1Category = consilMap.getKey(); LinkedList<String>
         * consiladatedList = consilMap.getValue();
         * 
         * 
         * for(int i=0;i<consiladatedList.size();i++) { String result =
         * consiladatedList.get(i);
         * 
         * String spliter[] = result.split(",");
         * 
         * for(int j=0;j<spliter.length;j++) { System.out.println(spliter[j]); }
         * 
         * }
         * 
         * }
         */
    }
}
 
     
     
    