Choosing datatype for field in JSON response [duplicate] Choosing datatype for field in JSON response [duplicate] json json

Choosing datatype for field in JSON response [duplicate]


You can instruct Jackson to "wrap" a single value in an array by enabling the ACCEPT_SINGLE_VALUE_AS_ARRAY feature:

Feature that determines whether it is acceptable to coerce non-array (in JSON) values to work with Java collection (arrays, java.util.Collection) types.

For example:

objectMapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);

Then as long as additionalServices is a collection type, deserialisation should succeed for a single-value or array.


In first JSON pass like this,

"configuration": {   "additionalServices": [{      "type": "Standard DDOS IP Protection"    }], }