users@jersey.java.net

[Jersey] JSON serialization to object lists instead of array

From: Michael Justin <michael.justin_at_gmx.net>
Date: Sun, 10 Jul 2011 12:51:34 +0200

Is it possible to configure the JSON representation in Jersey to
generate object lists instead of arrays like in this example? (found
[here][1])

     {
       "accomodations" : [
         {
           "accomodation" : {
             "name": "...",
             "category": "couch",
             "uri": "http://example.org/accomodations/accomodation_1"
           }
         },
         {
           "accomodation": {
             "name": "...",
             "category": "room",
             "uri": "http://example.org/accomodations/accomodation_2"
           }
         }
       ]
     }

If I try using a `List<Accomodation>`, the result looks like


     {
       "accomodations" : [
         {
             "name": "...",
             "category": "couch",
             "uri": "http://example.org/accomodations/accomodation_1"
         },
         {
             "name": "...",
             "category": "room",
             "uri": "http://example.org/accomodations/accomodation_2"
         }
       ]
     }

   [1]:
http://stackoverflow.com/questions/2737809/restful-api-how-to-model-json-representation/2739537#2739537

Regards
Michael Justin