Jersey: Json array with 1 element is serialized as object

前端 未结 8 2125
眼角桃花
眼角桃花 2021-01-03 19:20

I\'m creating a REST server with Jersey/Java and I found a strange behavior.

I have a method on the server that returns an array of objects as Json

@         


        
8条回答
  •  花落未央
    2021-01-03 19:50

    You could use Jettison (coming with Jersey) and prepare the structure you would like to have yourself using JSONObject and JSONArray as return values. They are in the package org.codehaus.jettison.json of jettison-1.3.2.jar which is a transitive dependency of jerysey-json

提交回复
热议问题