0

I am upgrading from Jersey1.x to Jersey2.x. The REST web-service has a List<List<String>> which with 1.x was returning the response as:

"values" :[  
   [  
      "Value1_1",
      "Value1_2",
      "Value1_3"
   ],
   [  
      "Value2_1",
      "Value2_2",
      "Value2_3"
   ],
   [  
      "Value3_1",
      "Value3_2",
      "Value3_3"
   ]
]

With 2.x, it flattens out the inner list and response shows up as:

"values" : [
    "Value1_1 Value1_2 Value1_3",
    "Value2_1 Value2_2 Value2_3",
    "Value3_1 Value3_2 Value3_3"
]

(@JsonUnwrapped has not been added).

Assuming that we have to continue working with this type which produces a list if strings (and not change to List which produces a list of objects), how can we achieve a similar output.

Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720

1 Answers1

0

Jackson would not produce this result. When I tested with MOXy as the provider though, I did get this result. Make sure you are using Jackson and not MOXy. If you have jersey-media-moxy as dependency, remove it. Make sure you have the jersey-media-json-jackson dependency. And register the JacksonFeature.

Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720
  • Ahh... You are absolutely right.Thanks for pointing me in right direction. After getting your input i read this link to get things working: https://stackoverflow.com/questions/18317927/force-glassfish4-to-use-jackson-instead-of-moxy – BlueJay Apr 26 '18 at 20:41