Search in sources :

Example 71 with JSONArray

use of net.minidev.json.JSONArray in project knox by apache.

the class ListResourcesRequest method parseResourceNames.

protected List<String> parseResourceNames(BasicResponse response) throws Exception {
    List<String> result = new ArrayList<>();
    JSONObject json = (JSONObject) new JSONParser(0).parse(response.getBytes());
    if (json != null) {
        JSONArray items = (JSONArray) json.get("items");
        if (items != null) {
            for (Object item1 : items) {
                JSONObject item = (JSONObject) item1;
                String name = (String) item.get("name");
                if (name != null) {
                    result.add(name.substring(0, name.lastIndexOf('.')));
                }
            }
        }
    }
    return result;
}
Also used : JSONObject(net.minidev.json.JSONObject) ArrayList(java.util.ArrayList) JSONArray(net.minidev.json.JSONArray) JSONParser(net.minidev.json.parser.JSONParser) JSONObject(net.minidev.json.JSONObject)

Aggregations

JSONArray (net.minidev.json.JSONArray)71 JSONObject (net.minidev.json.JSONObject)52 Test (org.junit.Test)13 HashMap (java.util.HashMap)10 JSONParser (net.minidev.json.parser.JSONParser)10 ArrayList (java.util.ArrayList)9 Map (java.util.Map)9 HashSet (java.util.HashSet)6 List (java.util.List)6 UnsupportedEncodingException (java.io.UnsupportedEncodingException)5 JSONConverterException (org.btrplace.json.JSONConverterException)5 Test (org.testng.annotations.Test)5 DocumentContext (com.jayway.jsonpath.DocumentContext)3 JsonPath (com.jayway.jsonpath.JsonPath)3 Option (com.jayway.jsonpath.Option)3 ContentType (ddf.catalog.data.ContentType)3 SourceInfoResponse (ddf.catalog.operation.SourceInfoResponse)3 SourceInfoRequestEnterprise (ddf.catalog.operation.impl.SourceInfoRequestEnterprise)3 SourceDescriptor (ddf.catalog.source.SourceDescriptor)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3