JAX-RS: is there a serializer for json for the root element, part of the list, parameter in the web service

I am currently developing a RESTful API and using JAX-RS for the backend. Many repons have the following simple form:

{
  "someList": [
    "item1" : ...,
    "item2" : ...,
    "itemn" : ...
  ]
}

The name of the array field is important. Required by client (EmberJS data). I am trying to create answers with a standard ResponseBuilder, but I do not know how to determine the field name for the list. All the answers I get are as follows:

[
  "item1" : ...,
  "item2" : ...,
  "itemn" : ...
]

In the past, I always created a container class with one property for a list. It works, but I think there should be a better solution. Maybe a helper class for converting other objects?

+4
source share
1

JSON-Serializer. Jettison ( , EnvelopeObject ).

Jackson, SerializationFeature.WRAP_ROOT_VALUE ( DeserializationFeature).

@JsonRootName, Jackson-Annotations @XmlRootElement, JAXB-.

+3

Source: https://habr.com/ru/post/1537074/


All Articles