I would like to serialize a Java HashMap to string representation. The HashMap will contains only primitive values like string and integer. After that this string will be stored to db. How to restore back the HashMap? Is it make sense to use BeanUtils and interface Converter or use JSON?
For example:
List list = new ArrayList();
list.add(new Long(1));
list.add(new Long(2));
list.add(new Long(4));
Map map = new HashMap();
map.put("cityId", new Integer(1));
map.put("name", "test");
map.put("float", new Float(-3.2));
map.put("ids", list);
map.toString() -> {float=-3.2,ids=[1, 2, 4],name=test,cityId=1}
map.toJSON -> {"float":-3.2,"ids":[1,2,4],"name":"test","cityId":1}