자바 HashMap을 문자열 표현으로 직렬화하고 싶습니다. HashMap에는 string 및 integer와 같은 프리미티브 값만 포함됩니다. 그 후에이 문자열은 db에 저장됩니다. HashMap을 복원하는 방법은 무엇입니까? BeanUtils 및 인터페이스 Converter을 사용하거나 JSON을 사용하는 것이 합리적입니까?String에서 HashMap으로 변환하는 가장 좋은 방법은 무엇입니까?
예를 들어:
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}
사람들이 Hibernate를 사용하는 이유는 이것이 아닙니까? – CPerkins
목록은 프리미티브가 아닙니다. objectinputstream과 objectoutputstream을 보셨습니까? –