Questions tagged [objectmapper]

ObjectMapper is a library for simple JSON object mapping in Swift.

ObjectMapper is a library for simple JSON object mapping in Swift.

1145 questions
2
votes
2 answers

How to validate json in kotlin

There is a kotlin class with the following structure. data class Person( @field:Length(max = 5) val name: String, val phones: List ) data class Phone( @field:Length(max = 10) val number: String ) When converting the json…
2
votes
1 answer

Jackson objectMapper gives different object for same json

I'm passing a json to objectmapper. The JSON string looks like this: { "id": "ID1", "identifier" : "XYZ", "data": [ { "id": "sampleParentID", "childrenElements": [ { "id" : "sampleChildID", "content" :…
Kancha
  • 409
  • 1
  • 3
  • 11
2
votes
2 answers

Java ObjectMapper.readValue turns generic type to LinkedHashMap

@Service public class PokemonManager implements PokemonService { private HttpResponse getStringHttpResponseByUrl(final String url) { HttpClient httpClient = HttpClient.newHttpClient(); HttpRequest request =…
Fatih Enes
  • 77
  • 5
2
votes
1 answer

Remove sensitive-data from exception logs during serialize/deserialize JSON content while using com.fasterxml.jackson.databind.ObjectMapper

Context: We are using com.fasterxml.jackson.databind.ObjectMapper's readValue() method to convert JSON to Java POJO. When the JsonParseException or JsonMappingException occurs, the original data excerpts (JSON content) is being printed in the…
Ray
  • 21
  • 2
2
votes
0 answers

How to write object mapper to DE serialize the response json date to xmlgregoriancalendar date with springboot and jackson

org.springframework.web.client.RestClientException: Error while extracting response JSON parse error: Cannot deserialize value of type javax.xml.datatype.XMLGregorianCalendar from String "1983-02-09T00:00:00:000Z": not a valid textual…
2
votes
1 answer

Format Date with OpenFeign

My Feign client is defined as follow : @FeignClient(name = "${feign.name}",url = "${feign.url}", configuration = {DateFormatConfiguration.class}) public interface MyFeignClient { @GetMapping(value = "/test") ResponseEntity
Mohamed Taboubi
  • 6,663
  • 11
  • 55
  • 87
2
votes
1 answer

Jooq fetchInto class java.util.LinkedHashMap cannot be cast to class

Giving the last example given in this SO thread. I get this error: java.lang.ClassCastException: class java.util.LinkedHashMap cannot be cast to class com.example.dtos.UserElement (java.util.LinkedHashMap is in module java.base of loader…
aiqency
  • 1,015
  • 1
  • 8
  • 22
2
votes
2 answers

autowired ObjectMapper is null during @DataJpaTest

I want to test my implementation for AttributeConverter using @DataJpaTest. test code @RunWith(SpringRunner.class) @DataJpaTest @AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) class FooRepositoryTest { @Autowired …
Kiwon Seo
  • 69
  • 5
2
votes
1 answer

Mockito multiple ObjectMapper values

im mocking mapper.convertValue to return 2 different return type of same class. Target target1 = new Target(); target1.setId("123); Target target2 = new Target(); target2.setId("345); Mockito.when(mapper.convertValue(anyMap(),…
shdu12
  • 103
  • 3
  • 8
2
votes
0 answers

Parsing a JSON to nested class

I am having a JSON in which I have all the data as key-value pair. But my POJO is with nested class. How can I map the single level JSON into the nested class objects? My JSON looks like this: { "prototype" : { "name": "Deepak" …
Deepak Kumar
  • 1,246
  • 14
  • 38
2
votes
1 answer

How to map Alamofire 5.2 response with ObjectMapper in Swift5

I have a model like this: import UIKit import ObjectMapper struct Token: Mappable { var token: String? var deviceId: String? init?(map: Map) { } mutating func mapping(map: Map) { token <- map["token"] …
reza_khalafi
  • 6,230
  • 7
  • 56
  • 82
2
votes
2 answers

ObjectMapper doesn't fail on trailing characters

I'm having the following class: public class Car{ private String id; private String name; public Car() { } public Car(String id, String name) { this.id = id; this.name = name; } public String getId() { return id; } public void…
israel berko
  • 556
  • 1
  • 5
  • 18
2
votes
1 answer

How to override @JsonInclude from controller in Spring boot

I have a POJO class which has the annotation @JsonInclude(Include.NON_NULL) for the class. @JsonInclude(Include.NON_NULL) @Getter @Setter public class Attribute implements Serializable { private String type; private List value; …
Santosh Hegde
  • 3,420
  • 10
  • 35
  • 51
2
votes
1 answer

Object Mapper giving Exception: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field

I am consuming a spring boot application, On hitting the "/test/api" rest end point with a GET request from Postman, I am getting below error: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "userName" (class …
MarkD
  • 23
  • 1
  • 4
2
votes
1 answer

Create Unique Configuration between multiple Jackson mappers

Is there any interface in Jackson, or a better way to create the same configuration for multiple object mappers? For example, I have this both methods for the same class: public static File toCsv(List entityList) { final File tempFile =…