As others suggested, ordering should not matter. Nonetheless, if you prefer certain ordering, use @JsonPropertyOrder annotation like so:
@JsonPropertyOrder
@JsonPropertyOrder({ "x", "y", "x" })public class EntityObj {}
If alphabetical order suit you and you are using Spring Boot, you can add this in your application.properties :
application.properties
spring.jackson.mapper.sort-properties-alphabetically=true
I realized this doesn't work with variable names that start with upper case letters. For example a variable named "ID" will not be ordered.