-4

The error is last line throw 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());

My JSON:

[
    {
        "type": "folder",
        "name": "PAM",
        "path": "C:\\home\\sameer\\sample\\PAM",
        "id": "PAM6",
        "c‌​hildren": [
            {
                "type": "file",
                "name": "Country_Report_View_PAM.jasper",
                "path": "C:\\home\\‌​sameer\\sample\\PAM\\Country_Report_View_PAM.jasper",
                "id": "Country_Report_View_PAM.j‌​asper7",
                "children": []
            }
        ]
    }
]
Tom
  • 16,842
  • 17
  • 45
  • 54
jacob
  • 1
  • 3

1 Answers1

0

You are expecting a JSONObject but it is returning a JSONArray. Please check object's validity before use. Following post can be used to check JSONObject or JSONArray: Test if it is JSONObject or JSONArray

Community
  • 1
  • 1
Sachin Gupta
  • 7,805
  • 4
  • 30
  • 45