Is your feature request related to a problem? Please describe.
There is no way to configure the order that objects return their attributes in JSON Response. This leads to unintuitive responses though they are functionally the same. The order depends on the attribute names and their alphanumerical value and length it seems.
Describe the solution you'd like
I would like the order to be the same order in which the attributes are defined.
Describe alternatives you've considered
Otherwise adding annotations could achieve more fine-grained control, but seems too much and to verbose of a solution.
Additional context
To see the effect you can try:
public class Nonsense {
public int a;
public String b;
public Nonsense(int test, String test2) {
this.a = test;
this.b = test2;
}
}
and then
public class Nonsense {
public int c;
public String b;
public Nonsense(int test, String test2) {
this.c = test;
this.b = test2;
}
}
with a controller like this:
public class RootController extends HttpController {
@Inject
public WebApplication webApplication;
@Get("/")
public Nonsense getRoot() {
return new Nonsense(23, "HET");
}
}
Is your feature request related to a problem? Please describe.
There is no way to configure the order that objects return their attributes in JSON Response. This leads to unintuitive responses though they are functionally the same. The order depends on the attribute names and their alphanumerical value and length it seems.
Describe the solution you'd like
I would like the order to be the same order in which the attributes are defined.
Describe alternatives you've considered
Otherwise adding annotations could achieve more fine-grained control, but seems too much and to verbose of a solution.
Additional context
To see the effect you can try:
and then
with a controller like this: