deserialize list of strings into JSON in kotlin

I’m trying to deserialize the following string into JSON val myList ="""{"user_id": "id1" ,"old_user_ids": "["id1,id2,id3"]", "status":"ACTIVE"}""" I tried to deserialize using val record = objectMapper.readValue(myList, UserRecord::class.java) my data class looks like this data class UserRecord( var user_id: String = "", var old_user_ids: List<String> = emptyList(), var status: String = "" ) however, I’m getting the… Read More deserialize list of strings into JSON in kotlin

ObjectMapper returns null value on date field

My data is as below and saved in test folder with name risk.json [{ "Risk": "BN", "Classification": null, "LastDefaultDate": "1915-04-14 00:00:00" }] I have RiskClass defined as below @Data @JsonIgnoreProperties({"document"}) public class RiskClass implements KeyedObject { String risk; String classification; Date lastDefaultDate; @Override public String getKey() { return risk; } } In my data prepare… Read More ObjectMapper returns null value on date field

How to convert Object to Json String but with @JsonProperty instead of field names?

For a class similar to the following: class A{ @JsonProperty("hello_world") private String helloWorld; public String getHelloWorld(){…} public void setHelloWorld(String s){…} } When I try to convert it to a Json object via Obejct Mapper or GSON. new ObjectMapper().writeValueAsString(object); or gson.toJson(object); What I get is something like: { "helloWorld": "somevalue"; } however I need to have… Read More How to convert Object to Json String but with @JsonProperty instead of field names?

How to parse an array of objects without any key along with other fields using jackson in java

I have the following json sample [ { "owners": [ { "id": 1, "name": "abc", "accounts": [ { "number": 5, "region": "IND" }, { "number": 6, "region": "US" } ] }, { "id": 2, "name": "pqr", "accounts": [ { "number": 7, "region": "UK" } ] } ], "prop1": "xyz", "prop2": "abc" }, { "owners": [… Read More How to parse an array of objects without any key along with other fields using jackson in java