JSON fields unordered JSON fields unordered json json

JSON fields unordered


As others suggested, ordering should not matter. Nonetheless, if you prefer certain ordering, use @JsonPropertyOrder annotation like so:

@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 :

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.