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
6
votes
0 answers

The expression of type Map needs unchecked conversion

I have this in my code: ObjectMapper oMapper = new ObjectMapper(); Map objectMap = oMapper.convertValue(test, Map.class); And i receive the following warning: Type safety: The expression of type Map needs unchecked conversion to…
jdflores
  • 407
  • 7
  • 25
6
votes
2 answers

How to set jackson serialization depth level when using ObjectMapper?

Assuem that i have this below classes: public class Employee { private Department department; // other fields, getters and setters omited for brevtity } public class Department { private Address address; // other fields, getters…
Rasool Ghafari
  • 4,128
  • 7
  • 44
  • 71
6
votes
1 answer

Swift - Mapping of Nested Objects (Objectmapper)

I am developing an application with Swift 4. Where I make a call to the APIRest with Alamofire and I want to map the JSON response with Objectmapper. Well, the JSON that calls me back is the following: The code to the APIRest is: func…
6
votes
1 answer

Register JavaTimeModule with the default objectmapper in springboot

I define a JavaTimeModule: @Bean public Module java8TimeModule() { JavaTimeModule javaTimeModule = new JavaTimeModule(); return javaTimeModule; } However, it does not register itself with the default objectmapper. I am using…
Charles Ju
  • 1,095
  • 1
  • 9
  • 28
6
votes
3 answers

How to prevent ObjectMapper from converting escaped unicode?

I'm using Jackson 2.4 in Java to do some JSON legwork. I make a call to a remote server with Apache HttpGet, deserialize the results with Jackson into a POJO, manipulate those results, and then serialize them with Jackson to push back to a remote…
user1017413
  • 2,023
  • 4
  • 26
  • 41
6
votes
1 answer

Jackson Ignores Custom Field Deserializer When Value is "null"

I wrote a custom deserializer for Jackson for a certain field (follows). I use it with this annotation: @JsonDeserialize(using = TokenTypeDeserializer.class) TokenType type; It seems to work fine, as long as I pass a value in the field. When I…
Gil Shamgar
  • 578
  • 1
  • 6
  • 12
6
votes
5 answers

Ignoring Jackon JsonProperty Access for Unit Tests

I use Jackson for serialization/deserialization with my Spring Boot project. I have a DTO object with the following structure, public class TestDTO implements Serializable { private static final long serialVersionUID = 1L; private Long…
nixgadget
  • 6,983
  • 16
  • 70
  • 103
5
votes
2 answers

Convert JSON record to LinkedHashMap using Jackson API

I have a JSON file(it contains an array of JSON objects.) I am trying to read it object by object. Each object I need to convert it to a LinkedHashMap where both the key and value are strings. Note that even if the JSON objects…
Zeus
  • 319
  • 2
  • 13
5
votes
3 answers

How to parse field that may be a string and may be an array with Jackson

I'm new with java and objectMapper. I'm trying to parse json field that is possible that a key have two types, it could be a string or array. examples: { "addresses": [], "full_name": [ "test name_1", "test name_2" ], } or { { …
Diego Sanz
  • 55
  • 6
5
votes
1 answer

Performance difference - Jackson ObjctMapper.writeValue(writer, val) vs ObjectMapper.writeValueAsString(val)

Is there any significant performance difference between the following two? String json = mapper.writeValueAsString(searchResult); response.getWriter().write(json); vs mapper.writeValue(response.getWriter(), searchResult);
Sagar
  • 5,315
  • 6
  • 37
  • 66
5
votes
1 answer

Jackson: Check if ArrayNode contains JsonNode

I am using the Jackson JSON library and its Tree Model system (JsonNode) in my Java application. In this, I need to check if an ArrayNode contains a given JsonNode. I was looking through the JavaDocs and I did not see any sort of .contains() method…
Andrew
  • 902
  • 1
  • 11
  • 28
5
votes
2 answers

The import com.fasterxml.jackson.databind.ObjectMapper cannot be resolved

I'm trying to create a JSON file and i'm having trouble while trying to use ObjectMapper class. heres my class code: import java.math.BigDecimal; import org.springframework.web.bind.annotation.RequestMapping; import…
Felipe Bedê
  • 143
  • 2
  • 2
  • 4
5
votes
2 answers

Configure Dropwizard ObjectMapper for configuration to ignore unknown

With an ObjectMapper (com.fasterxml.jackson.databind) it's possible to specify that it should ignore unknown properties. This can either be done by adding @JsonIgnoreProperties(ignoreUnknown = true) on a class level or by setting it as default…
Myone
  • 1,103
  • 2
  • 11
  • 24
5
votes
2 answers

ObjectMapper failed to serialize response error Code=2

Im getting an error while hitting Alamofire get request using Alamofire Object mapper this is how i'm hitting the API- APIService.shared.getSlots{ (success,weekSlots, error) in if success { self.weekSlots = weekSlots! …
Romit Kumar
  • 2,442
  • 6
  • 21
  • 34
5
votes
0 answers

How to allow duplicate keys when using Jackson ObjectMapper

In the case of duplicates, ObjectMapper by default only keeps one of the elements as key. Namely, the last element will always be the one stored. For example: { "name" : "xyz", "name" : "abc" } If we use ObjectMapper readTree on the above tree,…
neid
  • 315
  • 1
  • 4
  • 12