How to make Jersey/Jackson serialize empty list; single element list as an array

前端 未结 4 1823
青春惊慌失措
青春惊慌失措 2021-01-18 13:14

Using Jersey and Jackson to create a REST interface, how do I get List fields to be serialized as a list when there are 0 or 1 elements in them. For example:



        
4条回答
  •  囚心锁ツ
    2021-01-18 13:23

    I am pretty sure that you are not actually using Jackson ("POJO" variant of JSON serialization), since Jackson would not convert single-element arrays or lists to anything else. So you are probably using one of legacy output methods (like jettison); meaning that if you configure system to use POJO mapping it should just work.

提交回复
热议问题