JBoss Community

Resteasy: Object to JSON capitalization?

created by Ben Meyer in JBoss Web Services - View the full discussion

Hi Guys,

I am pretty new to Resteasy and everything that belongs to it and I

have a tiny problem that sounds actually pretty easy to fix but I was not able to...

I have a JavaScript library which is expecting a capitalized JSON node.

Unfortunately I am not able to make any changes in that library so I need to

figure out a way, to fix this problem in the java part. I don't have anything fancy,

just 2 classes like this:

{code}

public class Body {

 

  private String def;

  private List<Employee> employees;

 

  public String getDef() {

 

    return def;

  }

 

  public void setDef(String def) {

 

    this.def = def;

  }

 

  public List<Employee> getItems() {

 

    return employees;

  }

 

  public void setItems(List<Employee> items) {

 

    employees = items;

  }

 

}

{code}

and

{code}

public class Employee {

 

  private String name;

 

  public String getName() {

 

    return name;

  }

 

  public void setName(String name) {

 

    this.name = name;

  }

 

}

{code}

 

The final JSON Code looks like this:

{"body":{"def":"Task","items":[{"name":"Test Name"}]}}

 

but I want it to look like this:

{"Body":{"Def":"Task","Items":[{"name":"Test Name"}]}}

 

Is there any way to handle this problem? Any annotation for renaming the nodes maybe?

 

Regards and thanks in advance,

pr0st

Reply to this message by going to Community

Start a new discussion in JBoss Web Services at Community