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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:24:07+00:00 2026-06-17T08:24:07+00:00

I have implemented a spring mvc 3 code to obtain JSON response (with help

  • 0

I have implemented a spring mvc 3 code to obtain JSON response (with help of jackson mapper)

@RequestMapping(value = "/getallroles", method = RequestMethod.GET)
@ResponseBody
public JsonJtableResponse1 getAllRoles(){
    List<Role> roleList = testService.getAllRoles();
    JsonJtableResponse1 jstr = new JsonJtableResponse1("OK",roleList);
    return jstr;
}

The JSON response object is like this.

public class JsonJtableResponse1 {

    private String Result;

    private List<Role> Records;

    public JsonJtableResponse1(String Result) {
        this.Result = Result;
    }

    public JsonJtableResponse1(List<Role> Records) {
        this.Records = Records;
    }

    public JsonJtableResponse1(String Result, List<Role> Records) {
        this.Result = Result;
        this.Records = Records;
    }

    public String getResult() {
        return Result;
    }

    public void setResult(String Result) {
        this.Result = Result;
    }

    public List<Role> getRecords() {
        return Records;
    }

    public void setRecords(List<Role> Records) {
        this.Records = Records;
    }   
}

returned JSON from spring method getAllRoles() is

{"result":"OK","records":[
{"custId":"1","name":"aaa","birthYear":"1982","employer":"XX","infoAsOfDate":"20130110","disabled":"true"},
{"custId":"2","name":"bbb","birthYear":"1982","employer":"YY","infoAsOfDate":"20130111","disabled":"true"},
{"custId":"3","name":"ccc","birthYear":"1982","employer":"XX","infoAsOfDate":"20130108","disabled":"false"},
{"custId":"4","name":"ddd","birthYear":"1981","employer":"TT","infoAsOfDate":"20130107","disabled":"true"}
]}

I need JSON as – [NOTE UPPER CASE R in both elements]

{"Result":"OK","Records":[ ....................
 ..............................................
]}

with Jakson mapper the JSON response is created taking in to account the getter/setter names of the object .How can I achieve the required format of JSON response?

  • 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-17T08:24:08+00:00Added an answer on June 17, 2026 at 8:24 am

    You can customized names using the annotation @JsonProperty:

    @JsonProperty("Result")
    public String getResult() {
        return Result;
    }
    

    If you need to have all your properties names to have the first letter to be in upper case, you could change the default naming convention by extending the PropertyNamingStrategy. For example you can read this blog post http://www.cowtowncoder.com/blog/archives/2011/03/entry_448.html.

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

Sidebar

Related Questions

I have this code for my Spring-based web project: Controller: @Controller @RequestMapping(mycontroller) public class
I have implemented spring security to protect sections of our website. I am using
I'm a newbie in Spring Batch. I have inherited a batch process implemented with
I have implemented correctly bump's api, and added this code: - (void) configureBump {
I have a Spring MVC that uses an external library which i have no
I implemented Dynamic DataSource Routing for Spring+Hibernate according to this article . I have
I'm using Spring Roo, and Spring MVC. I have Set up Spring Security to
I have a bunch of Hibernate mapped objects in my Spring MVC app. Default
I have an ASP MVC 3 application and in my Model I have implemented
I have developed a Spring MVC - Hibernate application as told here . Now

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.