apache / shenyu

Apache ShenYu is a Java native API Gateway for service proxy, protocol conversion and API governance.
https://shenyu.apache.org/
Apache License 2.0
8.44k stars 2.93k forks source link

[Question] <title>shenyu2.4.3版本 Report a jsonObject exception when an object contains a variable of type List #4746

Closed wanghe88 closed 1 year ago

wanghe88 commented 1 year ago

Question

post===>http://localhost:9195/dubbo/saveComplexBeanTest params==>{ "dubboTest": [{ "id": "123", "name": "test" }], "idLists": [ "456", "124" ], "idMaps": { "abc": "abc", "cbd": "cbd" } } 会抛出UnsupportedOperationException异常

GsonUtils方法jsonArrayToListInConvertToMap是有问题的

修改成: private List jsonArrayToListInConvertToMap(final JsonArray jsonArray) { List list = new ArrayList<>(jsonArray.size()); for (JsonElement jsonElement : jsonArray) { if (jsonElement.isJsonNull()) { list.add(null); continue; } String objStr = jsonElement.toString(); if (objStr.startsWith(LEFT_ANGLE_BRACKETS) && objStr.endsWith(RIGHT_ANGLE_BRACKETS)) { list.add(convertToMap(objStr)); } else { String asString = jsonElement.getAsString(); list.add(asString); } }

    return list;
}
fishguanhx commented 1 year ago

ok

fishguanhx commented 1 year ago

我也遇到这个问题了,这样修改很好!!!

fishguanhx commented 1 year ago

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。