use of org.json.simple.parser.JSONParser in project rest.li by linkedin.
the class ExampleD2Client method parseConfig.
private static JSONObject parseConfig() throws IOException, ParseException {
String path = new File(new File(".").getAbsolutePath()).getCanonicalPath() + "/src/main/config/client.json";
JSONParser parser = new JSONParser();
Object object = parser.parse(new FileReader(path));
return (JSONObject) object;
}
use of org.json.simple.parser.JSONParser in project hadoop by apache.
the class HttpFSFileSystem method createXAttrNames.
/** Convert xAttr names json to names list */
private List<String> createXAttrNames(String xattrNamesStr) throws IOException {
JSONParser parser = new JSONParser();
JSONArray jsonArray;
try {
jsonArray = (JSONArray) parser.parse(xattrNamesStr);
List<String> names = Lists.newArrayListWithCapacity(jsonArray.size());
for (Object name : jsonArray) {
names.add((String) name);
}
return names;
} catch (ParseException e) {
throw new IOException("JSON parser error, " + e.getMessage(), e);
}
}
use of org.json.simple.parser.JSONParser in project hadoop by apache.
the class TestHttpFSServer method getPerms.
/**
* Given the JSON output from the GETFILESTATUS call, return the
* 'permission' value.
*
* @param statusJson JSON from GETFILESTATUS
* @return The value of 'permission' in statusJson
* @throws Exception
*/
private String getPerms(String statusJson) throws Exception {
JSONParser parser = new JSONParser();
JSONObject jsonObject = (JSONObject) parser.parse(statusJson);
JSONObject details = (JSONObject) jsonObject.get("FileStatus");
return (String) details.get("permission");
}
use of org.json.simple.parser.JSONParser in project hadoop by apache.
the class TestHttpFSServer method getAclEntries.
/**
* Given the JSON output from the GETACLSTATUS call, return the
* 'entries' value as a List<String>.
* @param statusJson JSON from GETACLSTATUS
* @return A List of Strings which are the elements of the ACL entries
* @throws Exception
*/
private List<String> getAclEntries(String statusJson) throws Exception {
List<String> entries = new ArrayList<String>();
JSONParser parser = new JSONParser();
JSONObject jsonObject = (JSONObject) parser.parse(statusJson);
JSONObject details = (JSONObject) jsonObject.get("AclStatus");
JSONArray jsonEntries = (JSONArray) details.get("entries");
if (jsonEntries != null) {
for (Object e : jsonEntries) {
entries.add(e.toString());
}
}
return entries;
}
use of org.json.simple.parser.JSONParser in project hadoop by apache.
the class TestHttpFSServer method getPath.
/**
* Given the JSON output from the GETTRASHPATH call, return the
* 'path' value.
*
* @param statusJson JSON from GETTRASHPATH
* @return The value of 'path' in statusJson
* @throws Exception
*/
private String getPath(String statusJson) throws Exception {
JSONParser parser = new JSONParser();
JSONObject details = (JSONObject) parser.parse(statusJson);
return (String) details.get("Path");
}
Aggregations