[BUG] JSONArray Cast Exception
Cooper-Zhong opened this issue · comments
Cooper commented
问题描述
ClassCastException: class com.alibaba.fastjson2.JSONArray cannot be cast to class com.alibaba.fastjson.JSONArray
环境信息
- OS信息: [e.g.:MacOS 12.7.4 Apple M1 Pro 16GB]
- JDK信息: [e.g.:Openjdk 17.0.6 ]
- 版本信息:[e.g.:Fastjson 2.0.49]
重现步骤
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONPath;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
public class Issue113_Mutated_137 {
@Test
public void test() {
String testJson2 = "{\"result\":[{\"puid\":\"21025318\"},{\"puid\":\"21482682\"},{\"puid\":\"21025345\"}],\"state\":0}";
JSONArray result2 = (JSONArray) JSONPath.extract(testJson2, "$.result[0,2].puid");
assertNotNull(result2);
assertEquals("[\"21025318\",\"21025345\"]", result2.toJSONString());
}
}
期待的正确结果
在Fastjson2-2.0.49中 测试正常
相关日志输出
java.lang.ClassCastException: class com.alibaba.fastjson2.JSONArray cannot be cast to class com.alibaba.fastjson.JSONArray (com.alibaba.fastjson2.JSONArray and com.alibaba.fastjson.JSONArray are in unnamed module of loader 'app')
Shaojin Wen commented
https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson/2.0.50-SNAPSHOT/
问题已修复,请帮忙用2.0.50-SNAPSHOT版本验证,2.0.50版本预计在5月12日前发布
Shaojin Wen commented
https://github.com/alibaba/fastjson2/releases/tag/2.0.50
2.0.50已发布,请用新版本