json转map集合
时间: 2023-09-17 14:09:19 浏览: 277
要将JSON转换为Map集合,可以使用JSONObject类的parseObject方法。方法的参数是一个JSON字符串,返回一个Map对象。下面是代码示例:
```
String json = "{\"key1\":\"value1\",\"key2\":\"value2\",\"key3\":\"value3\"}";
Map<String, Object> map = JSONObject.parseObject(json, new TypeReference<Map<String, Object>>() {});
```
这样就可以将JSON字符串转换成Map集合了。其中,key1、key2、key3是JSON中的键,对应的value1、value2、value3是键对应的值。你可以根据需要自行修改JSON字符串和键的名称。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [java json转map](https://blog.csdn.net/qq_47870876/article/details/119423975)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [json字符串转化为map](https://blog.csdn.net/qq_35490522/article/details/108193719)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文