作者 朱兆平

处理匿名者访问方法转json对象异常问题

1 package com.example.gateway.filter; 1 package com.example.gateway.filter;
2 2
3 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
  4 +import com.alibaba.fastjson.JSONArray;
4 import com.alibaba.fastjson.JSONObject; 5 import com.alibaba.fastjson.JSONObject;
5 import com.example.gateway.model.PERMISSION; 6 import com.example.gateway.model.PERMISSION;
6 import com.example.gateway.model.ROLE; 7 import com.example.gateway.model.ROLE;
@@ -173,7 +174,7 @@ public class WrapperResponseGlobalFilter implements GlobalFilter, Ordered { @@ -173,7 +174,7 @@ public class WrapperResponseGlobalFilter implements GlobalFilter, Ordered {
173 String json = stringRedisTemplate.opsForValue().get(redisKey); 174 String json = stringRedisTemplate.opsForValue().get(redisKey);
174 if(json!=null && !json.isEmpty()){ 175 if(json!=null && !json.isEmpty()){
175 try{ 176 try{
176 - JSONObject jsonObject = JSONObject.parseObject(json); 177 + JSONArray jsonObject = JSONArray.parseArray(json);
177 List<ROLE> roleList = JSONObject.toJavaObject(jsonObject,List.class); 178 List<ROLE> roleList = JSONObject.toJavaObject(jsonObject,List.class);
178 if(roleList!=null && !roleList.isEmpty()){ 179 if(roleList!=null && !roleList.isEmpty()){
179 for (ROLE role: roleList){ 180 for (ROLE role: roleList){