I am developing an API Rest with Jersey and I am using JAXB and with the annotation @XmlRootElement
@XmlRootElement
public class Car {
private int idCar;
private String model;
private String color;
public Car() {
}
public Car(String model, String color) {
setModel(model);
setColor(color);
}
public void setIdCar(int idCar) {
this.idCar = idCar;
}
public int getIdCar() {
return idCar;
}
public void setModel(String model) {
this.model = model;
}
public String getModel() {
return model;
}
public void setColor(String color) {
this.color = color;
}
public String getColor() {
return color;
}
@Override
public String toString() {
return "Car [model=" + model + ", color=" + color + "]";
}
}
I am converting a Car Class to JSON with Jersey to return it when requesting the resource
@GET
@Path("/{num : \d+}")//digit only
@Produces(MediaType.APPLICATION_JSON)
public Car getCar(@PathParam("num") int id) {
Car objCar = ConnectionDB.getCarDB(id);
return objCar;
}
But when doing the Get Me change the JSON Order
How does jaxb mapping work to make it look like this?