2017-03-08 110 views
0

我想寫一個JSONPath表達式來檢查active=true這個簡單的對象。使用JSONPath檢查布爾值

{ 
    "active": true 
} 

這是可能的JSONPath?我似乎無法讓它在任何聯機JSONPath評估器中工作。

回答

0

我認爲有以下應該工作

final Configuration conf = Configuration.defaultConfiguration(); 
try { 
    Object returnObj = JsonPath.using(conf).parse(responseBody).read("$.active"); 
System.out.println(returnObj); 
} 
catch (PathNotFoundException e){ 
    System.err.println("JsonPath not found : " + path); 
}