How do I go about splitting the following string using Java?
{525={174=2, 133=1, 182=1}}
There can be multiple lines similar to above. Each of them is a combination for the outer HashMap. Assuming there is another line
{500={100=2, 150=1, 200=1}}
The desired structure would be
525 -> 174 -> 2
133 -> 1
182 -> 1
500 -> 100 -> 2
150 -> 1
200 -> 1
I want to have the numbers in a Hashmap>.
Here is what I tried:
String s="{525={174=2, 133=1, 182=1}}";
HashMap<Integer, HashMap<Integer, Integer>> fullMap = new HashMap<Integer, HashMap<Integer, Integer>>();
Integer key, innerKey, innerValue;
key = Integer.parseInt(s.split("=")[0].replace("{",""));
I'm new to Java and don't know how to proceed further.
{and}(basically code a pushdown automaton).