I use the last branch for the Jackson module - jackson-module-jsonSchema, i.e. 2.4.4-Snapshot.
I am trying to use the @JsonPropertyOrder annotation to maintain the order of the POJO attributes, but does not seem to abide by the annotation.
My POJO example is as follows:
import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonPropertyOrder({"a", "b"}) class Pojo { private String a; private String b; public Pojo(final String a, final String b) { this.a = a; this.b = b; } public void setA(final String a) { this.a = a; } public void setB(final String b) { this.b = b; } public String getA() { return this.a; } public String getB() { return this.b; } }
Jackson's code is as follows:
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jsonSchema.JsonSchema; import com.fasterxml.jackson.module.jsonSchema.factories.SchemaFactoryWrapper; public class Test { public static void main(String[] args) throws JsonProcessingException {
Json output is as follows:
{ "type": "object", "id": "urn:jsonschema:Pojo", "properties": { "b": { "type": "string" }, "a": { "type": "string" } } }
Can someone suggest that I am doing something wrong or we need to open the problem on Jackson, as I can see that this problem is already closed in 2.3.2 ( https://github.com/FasterXML/jackson-dataformat- xml / issues / 91 )?
source share