Q:

Converting strings to Map in java

How should I convert {A=1,B=2,C=3} into map type object like {'A':"1",'B':"2",'C':"3"} in java ?Is there any existing API to do this?

A:

You can simply use split() and do something like this:
public static void main (String[] args) throws Exception {
    String input = "{A=1,B=2,C=3}";
    Map<String, Integer> map = new HashMap<>();
    for(String str : input.substring(1,input.length() - 1).split(",")) {
        String[] data = str.split("=");
        map.put(data[0],Integer.parseInt(data[1]));
    }
    System.out.println(map);
}

Output:
{A=1, B=2, C=3}

