0
我想提取字符串列表清單串名單我想@name值的列表。我使用jayway jsonpath來做到這一點。從下面的Json</p> <pre><code>"example":{[ {"@name":"name1"}, {"@name":"name2"}, {"@name":"name3"}, {"@name":"name4"} ]} </code></pre> <p>獲取從JSON對象
我嘗試下面的代碼,
List<String> response = null;
try{
ReadContext ctx = JsonPath.parse(data);
response = ctx.read(xPath);
}catch(Exception e){
AppLogger.EventLogger.error(e.getMessage());
response = null;
}
return response;
,但有一個例外,說找不到指定的路徑。我已經使用了以下jsonPath [email protected]
有人能告訴我我的代碼中出了什麼問題?如何提取列表@name值。
預期輸出:
[name1,name2,name3,name4]
首先,它看起來不像有效的JSON ... –
@SouravGanguly,謝謝。但認爲它是有效的Json :) – Backtrack