今天在解析Json数据时碰到一个超级奇怪的现象:
在浏览器上查询得到的Json数据为(以xml形式显示):
<intentionResponse>null</intentionResponse>
然后我自己的java代码为:
public static String extractIntentionResponse(String intentionResponse){
if(intentionResponse!=null) {
System.out.println(intentionResponse);
}
//sout打印输出结果为:null
我当时就震惊了,你不是null吗!那你咋还能进入if
判断条件内部啊。
此时就显现出debug的强大威力了:
进入debug,查看具体对象,发现:intentionResponse=“null”
所以找到原因了,intentionResponse不是null对象,而是"null"字符串!