Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9071377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:53:45+00:00 2026-06-16T17:53:45+00:00

I am implementing an example here I need the output json to name the

  • 0

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();

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T17:53:46+00:00Added an answer on June 16, 2026 at 5:53 pm

    You need your Entity Class to contain an instance of List<FileMeta> called files to have that JSON Output.

    public Class EntityClass
    {
      private List<FileMeta> files;
      //Getter and Setter Methods.
    }
    

    Here’s what you need to have in redirect method.

    @GET
    @Path("/{key}/meta")
    @Produces(MediaType.APPLICATION_JSON)
    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> meta = Lists.newArrayList(meta);
    EntityClass entity= new EntityClass();
    entity.setFiles(meta);
    return Response.ok(entity).build();
    }
    

    PS: Additionally, you need to configure POJOMapping in your web.xml.

    <init-param>
      <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
      <param-value>true</param-value>
    </init-param>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am implementing the nerd dinner example in MVC2. The problem which I am
I've been using Android open source service example. I just need to use it
I'm implementing MVVM for a class which represents recursively nested types. For example: class
I am implementing a RESTful web service that currently handles JSON and needs to
I've tried implementing this example , but the progress never displays. My page doesn't
I'm implementing an example, in that example, I read in data from a database,
Could someone provide some example on implementing SEH in VB6? Everything I've seen so
Does anyone have a simple example of implementing an async validation rule in csla?
I'm trying to find a really good example for implementing the MetaWeblog API using
Every example I find of anyone implementing plugins in android seems to use aexp.intent.action.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.