[alibaba/fastjson]JSONPath报空指针

2024-09-02 244 views
2

代码 Object jsonObject = JSON.parse("{\"path\":\"\"}"); Object readResult = JSONPath.compile("$.path.docExt.a").eval(jsonObject);

错误 Exception in thread "main" java.lang.NullPointerException at com.alibaba.fastjson.JSONPath.getPropertyValue(JSONPath.java:3868) at com.alibaba.fastjson.JSONPath$PropertySegment.eval(JSONPath.java:2354) at com.alibaba.fastjson.JSONPath.eval(JSONPath.java:121)

源码: 这个地方是否需要增加判空 https://github.com/alibaba/fastjson/blob/7abc84fc2c208f148970ca854f2f6a59466e47ae/src/main/java/com/alibaba/fastjson/JSONPath.java#L3868 image

回答

7

这个问题在2.0.6中也存在,将会在2.0.6版本,你可以提issue到这里: https://github.com/alibaba/fastjson2/issues

意思是以后主要维护fastjson2,fastjson就只出bug修复么?

5

@neoflying 是的,后续主要是维护fastjson2