Have an array when the size is 1, the received json data does NOT contain []; as
{"firstname":"tom"}
when the size is greater than 1, the data I received contain [], for example
[{"firstname":"tom"},{"firstname":"robert"}]
Currently my class contains an array property
String[] firstname;
Code to handle this type
ObjectMapper mapper = new ObjectMapper();
MyClass object = mapper.readValue(json, MyClass.class);
When the size is greater than 1, deserialization works. However, when the size is 1, deserialization failed.
I am currently using jackson, any solution for this problem?
I am wondering if jackson / gson or any other library can handle this?
source
share