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

  • SEARCH
  • Home
  • 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 9181893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:25:49+00:00 2026-06-17T18:25:49+00:00

I am using dropwizard which uses jersey & jackson for json. My issue is

  • 0

I am using dropwizard which uses jersey & jackson for json. My issue is when I return a list it does not specify a root.

I have a POJO class:

public class Company { 
public String id; 
public String name; 
public String address; 
}

and my resource is set up thus:

@GET
@Path("/companies/all")
public List<Company> getAllCompanies(){
    ...
    return companies;
}

And I get the following response:

[{
"id": "01",
"name": "Yammer Corp",
"address": "1 Finite Loop"
},
{
"id": "02",
"name": "DropWizards Inc",
"address": "4 Magic Square, Olympus"
}]

While what I want is something like below:

{"Companies" : 
[{
"id": "01",
"name": "Yammer Corp",
"address": "1 Finite Loop"
},
{
"id": "02",
"name": "DropWizards Inc",
"address": "4 Magic Square, Olympus"
}
]}

Any ideas? Thanks in advance.

  • 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-17T18:25:50+00:00Added an answer on June 17, 2026 at 6:25 pm

    You need to create one more POJO wrapping the List<Company>

    public class ApiResponse
    {
       private List<Company> Companies;
       //Getter and Setter
       //Public Constructor
    }
    

    The Change required in your GET Method is:

    @GET
    @Path("/companies/all")
    public ApiResponse getAllCompanies(){
        //Set your ApiResponse Object with the companies List.
        ApiResponse apiResponse = new ApiResponse(companies);
        return apiResponse;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using dropwizard for writing a webapp and also using Jersey Client as
Using RestKit 0.10.1, I have objects served similar to this json format: {objects: [
Using getDefinitionByName I am consistently getting the error saying it is not defined (as
Using 2 dropDownLists in repeater row how does one use the 1st one as
Using Android NDK is it possible (from native C-code) to get a list of
Using server-side C#, how can I convert a querystring to a JSON string of
Using the classic code snippet: if (x & (x-1)) == 0 If the answer
Using C#.NET, i wrote a toolbar which is stored now into toolbar.cs file. I
using this code I can send one texture to the shader: devcon->PSSetShaderResources(0, 1, &pTexture);
Using intents to communicate between two activities seems not straightforward. Regardless of where (probably

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.