Can not deserialize instance of java.util.ArrayList out of START_OBJECT token

The problem is the JSON – this cannot, by default, be deserialized into a Collection because it’s not actually a JSON Array – that would look like this: [ { “name”: “Test order1”, “detail”: “ahk ks” }, { “name”: “Test order2”, “detail”: “Fisteku” } ] Since you’re not controlling the exact process of deserialization (RestEasy … Read more

Jackson overcoming underscores in favor of camel-case

You can configure the ObjectMapper to convert camel case to names with an underscore: objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE); Or annotate a specific model class with this annotation: @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) Before Jackson 2.7, the constant was named: PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES

Convert JsonNode into POJO

In Jackson 2.4, you can convert as follows: MyClass newJsonNode = jsonObjectMapper.treeToValue(someJsonNode, MyClass.class); where jsonObjectMapper is a Jackson ObjectMapper. In older versions of Jackson, it would be MyClass newJsonNode = jsonObjectMapper.readValue(someJsonNode, MyClass.class);

Different names of JSON property during serialization and deserialization

Just tested and this works: public class Coordinates { byte red; @JsonProperty(“r”) public byte getR() { return red; } @JsonProperty(“red”) public void setRed(byte red) { this.red = red; } } The idea is that method names should be different, so jackson parses it as different fields, not as one field. Here is test code: Coordinates … Read more

Java 8 LocalDate Jackson format

I was never able to get this to work simple using annotations. To get it to work, I created a ContextResolver for ObjectMapper, then I added the JSR310Module (update: now it is JavaTimeModule instead), along with one more caveat, which was the need to set write-date-as-timestamp to false. See more at the documentation for the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)