I am implementing an example here
I need the output json to name the array.
{"files":[]} instead of just {[]} which is what I’m currently getting as output. What do I need to do to add a name to the array?
@GET
@Path("/{key}/meta")
public Response redirect(@PathParam("key") String key) throws IOException {
BlobKey blobKey = new BlobKey(key);
BlobInfo info = blobInfoFactory.loadBlobInfo(blobKey);
String name = info.getFilename();
long size = info.getSize();
String url = "/rest/file/" + key;
FileMeta meta = new FileMeta(name, size, url);
List<FileMeta> metas = Lists.newArrayList(meta);
GenericEntity<List<FileMeta>> entity = new GenericEntity<List<FileMeta>>(metas) {};
return Response.ok(entity).build();
}
You need your Entity Class to contain an instance of
List<FileMeta>calledfilesto have that JSON Output.Here’s what you need to have in
redirectmethod.PS: Additionally, you need to configure POJOMapping in your web.xml.