页面访问偶尔慢 问题排查
页面访问偶0 0 使用fastjson,把一个JSON字符串反序列化成Map的错误。0
用的fastjons的版本是:
Java代码
1.1.1.41
1.1.41
json字符串如下:
Java代码
1.{
2. "user_id": 5300,
3. "flag": 0,
4. "configs": [
5. {
6. "user_id": 5300,
7. "config_item_id": 1015,
8. "type": 0
9. },
10. {
11. "user_id": 5300,
12. "config_item_id": 1016,
13. "type": 0
14. }
15. ]
16.}
{
"user_id": 5300,
"flag": 0,
"configs": [
{
"user_id": 5300,
"config_item_id": 1015,
"type": 0
},
{
"user_id": 5300,
"config_item_id": 1016,
"type": 0
}
]
}
反序列化代码如下:
Java代码
1.HashMap jsonMap = JSON.parseObject(jsonData, HashMap.class);
2.List configDataList = (List)jsonMap.get("configs");
3.for(HashMap configData : configDataList ){//这行出错
4. int roleId = (Integer)configData.get("type");
5. System.out.println("config.type:" + roleId);
6.}