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

Convert String type JSON to Integer with ObjectMapper

I have my model class class CPOption : Object, Mappable { dynamic var optionId : Int64 = 0 override static func primaryKey() -> String? { return "optionId" } required convenience init?(map: Map) { self.init() } func mapping(map: Map) { …
NaXir
  • 2,373
  • 2
  • 24
  • 31
2
votes
1 answer

Generalizing a function to map JSON to Object using ObjectMapper and swift 3

I´m developing a project in Swift 3 using ObjectMapper and I have a lot of functions using the same code. The function which does the conversion is this: func convertCategories (response:[[String : Any]]) { let jsonResponse =…
2
votes
1 answer

com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of VALUE_NUMBER_INT token

I am trying to load a String value into List of Integers , here is the sample code import java.util.List; public class Test2 { private List list; public List getList() { return list; } public void setList(List list)…
Sat
  • 3,520
  • 9
  • 39
  • 66
2
votes
0 answers

Generic DataResponse with Alamofire and ObjectMapper

I want to create a custom class for Alamofire so I will be able to call the request over and over again in various classes. In order to do that I need to pass the model class that extends to Mappable in DataResponse. But I got many errors. This is…
2
votes
1 answer

How to map multi-dimensional array of JSON response with Alamofire+ObjectMapper?

I am trying to start my project with Alamofire+ObjectMapper. I can do simple mapping with array of objects (with keys). However, this is a must case I have to do with the following kind of JSON format, which have some problems: 1: It's very nested…
KTang
  • 340
  • 1
  • 17
2
votes
1 answer

Jackson deserialize array with empty object

I have the following JSON: {"beans":["{}",{"name":"Will"}]} and the corresponding POJO classes: public class BeanA { private BeanB[] beans; ...getters/setters } public class BeanB { private String name; ...getters/setters } I…
Will Huang
  • 325
  • 7
  • 15
2
votes
1 answer

Swift 4 - Issue with ObjectMapper while parsing JSON

My code was working perfectly before Swift 4, I am just parsing a simple JSON file, and I am mapping everything into my model class. Here is my example code : First of all I get my json file. if let path = Bundle.main.path(forResource: "myFile",…
user7219266
2
votes
0 answers

How can I handle false as null for any primitive or boxed numerical bean property in Jackson?

I've been struggling with an issue. My endpoint receives a lot of broken API calls from a PHP application where there are often false booleans set for numerical fields. How can I attach a custom deserializer to my ObjectMapper that would convert all…
Mridang Agarwalla
  • 43,201
  • 71
  • 221
  • 382
2
votes
4 answers

Read from file and parse them into different arrays

I'll read a file content as an input for my program. I'm storing it into a string and splitting it into 2 string. File file = new File("question.txt"); PrintWriter pw = new PrintWriter(file); pw.write("81 : (1,53.38,$45) (2,88.62,$98) (3,78.48,$3)…
Vaibhav Rai
  • 183
  • 1
  • 8
2
votes
2 answers

Having trouble deserialzing null Jackson node to a collection

I'm testing deserializing to a collection object when my JsonNode no value. I want the object to be equal to null. This is what I'm trying: public class ImmutableDiscoveredUrlDeserializer extends JsonDeserializer { String…
CNDyson
  • 1,687
  • 7
  • 28
  • 63
2
votes
1 answer

How to map [Color] to [String:Color] using ObjectMapper

I'm trying to map JSON of an Array type to a Dictionary and i'm not quite sure how to do it using ObjectMapper. Example JSON: { "colors": [ { "id": "red", "r": "255", "g": "255", "b": "255" } ] }
ap147
  • 162
  • 7
2
votes
1 answer

Map JSON to the model irrespective of Array or Object - ObjectMapper

I am having trouble in mapping the JSON to my object class. Here is my Model Object class CityObject : NSObject, Mappable{ var id : String? var name : String? required init?(map: Map) { } func mapping(map: Map) { id <- map["id"] name <-…
Naveen T P
  • 6,955
  • 2
  • 22
  • 29
2
votes
0 answers

Spring Boot application has about 20 ObjectMappers

I'm trying to configure the Jackson ObjectMapper in a Spring Boot application. I've tried various approaches as suggested here and in the documentation (e.g. using a Jackson2ObjectMapperBuilder or Jackson2ObjectMapperBuilderCustomizer @Bean). I want…
2
votes
1 answer

Swift use ObjectMapper with singleton

I want use ObjectMapper to parsing Json string within a singleton situation. Example code : class User: Mappable { var username: String? var signature: String? //Singleton static let shared = User() private init() {} …
Hongxu Jin
  • 817
  • 2
  • 9
  • 16
2
votes
1 answer

Serialize floats to JSON in Swift without dropping decimal

Scenario: I have a schemaless database API that infers type based on json passed into it. Once the database infers schema however, all subsequent entries added to the same table must follow the existing schema. I'm pushing json-formatted data to a…
Ben Lieber
  • 113
  • 1
  • 7