英文:
Contruct json into Map<String, Object>
问题
map.put("only", Arrays.asList("meta", "data", "thead"));
英文:
I want to construct the following json into a Map<String, Object>
{"tm":"3-ticker-payout-history-full-screen","r":"ES","default_tab":"overview","slug":"alt-group","only":["meta","data","thead"]}
Below is what I have so far
Map<String, Object> map = new HashMap<>();
map.put("tm", "3-ticker-payout-history-full-screen");
map.put("slug", "alt-group");
map.put("r", "ES");
map.put("default_tab", "overview");
How would I add "only":["meta","data","thead"]
to the hashmap?
答案1
得分: 2
你可以创建一个 List<String>
,并将 "meta","data","thead"
添加到列表中,然后将该 List<String>
添加到地图中。
英文:
You can create a List<String>
and add "meta","data","thead"
to the list, then add the List<String>
to the map.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论