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 8958901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:19:23+00:00 2026-06-15T15:19:23+00:00

So, to start I have this class: public class PaginatedList<?> extends ArrayList<?>{ private int

  • 0

So, to start I have this class:

    public class PaginatedList<?> extends ArrayList<?>{
       private int startIndex;
       private int endIndex;

       public PaginatedList(int startIndex, int endIndex...){
           this.startIndex = startIndex;
           this.endIndex = endIndex;
           //Do pagination stuffs.
       }
    }

and this class:

    public class UserList extends PaginatedList<User>{

       public UserList(int startIndex, int endIndex...){
          super(startIndex, endIndex...);
       }

    }

Now, when I have my resource return a UserList, it prints out the list of users as expected:

[
  {
    "userName":"binky",
    "age":115
  }
]

But, I want the output to be like this:

{
  "users":
   [
     {
       "userName":"binky",
       "age":115
     }
   ],
  "pagination":
   {
     "startIndex":5,
     "endIndex":10
   }
}

So, I annotate both of them with @JSONRootName(“”).

@JsonRootName("pagination")
public class PaginatedList extends ArrayList<?>{}
@JsonRootName("activities")
public class UserList extends PaginatedList<User>{}

and created a class to set up the ObjectMapper:

        @Provider 
        @Produces(MediaType.APPLICATION_JSON)
        public class Resolver implements ContextResolver<ObjectMapper>{

            private ObjectMapper objectMapper;

            public ObjectMapperProvider(){
                objectMapper = new ObjectMapper();
            }

            @Override
            public ObjectMapper getContext(Class<?> type) {
                if(type.getAnnotation(JsonRootName.class) != null){
                         objectMapper.configure(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE, true);
                }else{
                       objectMapper.configure(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE, false);
                }
                return objectMapper;
            }
        }

And still this implementation does not resolve my issue. The marshalled json does not return the unwrapped root values.

I am using jersey POJOMAPPING.

Any ideas?

  • 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-15T15:19:24+00:00Added an answer on June 15, 2026 at 3:19 pm

    It seems as though @JsonRootResource is more reserved for properties, not class level declarations. This should create a compilation error, but does not.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this Service class: public class BluetoothService extends Service { private static Activity
I have this service: public class AAAService extends Service { private Intent requestService; private
I have this class... public class StartStopTouple { public int iStart; public int iStop;
I have this code: public class Chronom extends Activity { Chronometer mChronometer; ProgressBar progre;
I have this code: public class JsoupParser { ArrayList<CompanyInfo> arr = new ArrayList<CompanyInfo>(); public
I have this PhaseListner: public class CheckAccessInterceptor implements PhaseListener { private static final long
I have this class called AudioInput: class AudioInput { private WaveIn waveIn; public delegate
I have this test class to test a remote service: public class CoreServiceBasicTest extends
I have this structure in my program: class Node0 private Server server; ... public
I have this class: public class SaveState implements Serializable { private static final long

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.