错误是最后一行抛出JsonException
Client client = Client.create();
WebResource webResource = client.resource(baseUrl+"/jaspertemplate");
ClientResponse respons = webResource.accept("application/json")
.get(ClientResponse.class);
String output = respons.getEntity(String.class);
JSONObject obj1 = new JSONObject(output.trim());
我的JSON:
[
{
"type": "folder",
"name": "PAM",
"path": "C:\\home\\sameer\\sample\\PAM",
"id": "PAM6",
"children": [
{
"type": "file",
"name": "Country_Report_View_PAM.jasper",
"path": "C:\\home\\sameer\\sample\\PAM\\Country_Report_View_PAM.jasper",
"id": "Country_Report_View_PAM.jasper7",
"children": []
}
]
}
]
答案 0 :(得分:0)
你期待一个JSONObject,但它正在返回一个JSONArray。 请在使用前检查对象的有效性。 以下帖子可用于检查JSONObject或JSONArray: Test if it is JSONObject or JSONArray