jackson deserialize array into a java object

前端 未结 2 1191
一生所求
一生所求 2021-01-20 21:53

I have json\'ed array of host, port, uri tuples encoded by 3rd party as an array of fixed length arrays:

[
  [\"www1.example.com\", \"443\", \"/         


        
2条回答
  •  醉话见心
    2021-01-20 22:23

    Add following annotation:

    @JsonFormat(shape=JsonFormat.Shape.ARRAY)
    class Endpoint {
    }
    

    and it should serialize entries as you wish.

    Also: it'd be safest to then use @JsonPropertyOrder({ .... } ) to enforce specific ordering, as JVM may or may not expose fields or methods in any specific order.

提交回复
热议问题