fastjson转map
时间: 2023-09-24 15:07:49 浏览: 103
fastjson常用方法
使用fastjson库将JSON字符串转换为Map对象的方法可以参考以下代码示例:
```java
String jsonString = "{\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}";
Map<String, Object> map = JSON.parseObject(jsonString, new TypeReference<Map<String, Object>>() {});
```
以上代码中,先定义了一个JSON字符串`jsonString`,然后使用`JSON.parseObject()`方法将其转换为Map对象。注意,为了正确地将JSON字符串转换为Map对象,需要使用`TypeReference`类来指定Map对象的键值对类型。
这样通过fastjson库的`JSON.parseObject()`方法,可以将JSON字符串转换为Map对象。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [FastJson之利用FastJson实现对象和Map互相转换*](https://blog.csdn.net/qq_41489540/article/details/109071292)[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_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [fastjson json字符串转map的几种方法](https://blog.csdn.net/u011149152/article/details/130092332)[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_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文