반응형
값이 null 인 맵 항목을 무시하는 Gson
Gson gson = new Gson();
Map<String,Object> map = new HashMap<String, Object>();
map.put("a", 1);
map.put("b", null);
System.out.println(gson.toJson(map)); //prints {"a":1}
모든 항목을 포함 시키려면 어떻게해야합니까?
http://sites.google.com/site/gson/gson-user-guide#TOC-Null-Object-Support를 참조 하십시오 .
Gson gson = new GsonBuilder().serializeNulls().create();
참고 URL : https://stackoverflow.com/questions/3923759/gson-ignoring-map-entries-with-value-null
반응형
'programing tip' 카테고리의 다른 글
LINQ를 사용하여 컬렉션을 n 개의 부분으로 나누시겠습니까? (0) | 2020.07.12 |
---|---|
Python의 특성 파일 (Java 특성과 유사) (0) | 2020.07.12 |
고스트 이미지의 드래그를 방지하는 CSS / JS? (0) | 2020.07.12 |
최적의 코드 너비에 대한 연구? (0) | 2020.07.12 |
WPF의 키보드 단축키 (0) | 2020.07.12 |