I'm currently playing around with RestEasy and Angular.js. I'm trying to return a collection or array of objects with all the attributes in the json. But when I perform the following method below, it only returns a JSON result of file names in string format. But I want all the attributes of the File class returned. Is there an easy way to do such in JSON with RestEasy?
@GET
@Produces("application/json")
@Path("/details/{location}")
public File[] getFolderDetails(@PathParam("location") String location) {
//List<File> folders = new ArrayList<File>();
File folder = new File(DIRECTORY_LOCATION + "/" + location);
File[] listOfFiles = folder.listFiles();
File folders[] = new File[listOfFiles.length];
int index = 0;
for (File listOfFile : listOfFiles) {
folders[index] = listOfFile;
index++;
}
return folders;
}
Currently this method returns something like:
["C:\jboss-4.2.2.GA\server\all","C:\jboss-4.2.2.GA\server\default","C:\jboss-4.2.2.GA\server\minimal","C:\jboss-4.2.2.GA\server\plu"]