Git Product home page Git Product logo

Comments (9)

JayachandraA avatar JayachandraA commented on June 18, 2024

Hello dude!, The same thing happening to me as well. When I run your code for single object it is giving
Error Domain=com.alamofire.error Code=-6004 "ObjectMapper failed to serialize response." UserInfo={NSLocalizedFailureReason=ObjectMapper failed to serialize response.}

let URL = "https://raw.githubusercontent.com/tristanhimmelman/AlamofireObjectMapper/d8bb95982be8a11a2308e779bb9a9707ebe42ede/sample_json"
Alamofire.request(.GET, URL).responseObject("data") { (response: Response<WeatherResponse, NSError>) in

let weatherResponse = response.result.value
print(weatherResponse?.location)

if let threeDayForecast = weatherResponse?.threeDayForecast {
    for forecast in threeDayForecast {
        print(forecast.day)
        print(forecast.temperature)           
    }
}

}

So please help me out of from this.

from alamofireobjectmapper.

macbaszii avatar macbaszii commented on June 18, 2024

@JayachandraA bad news, I dogged into the code and this library have just written an extension with own serializer and fixed error message for us.

I think the proper way is clone this repository and edit the serializer yourself.

from alamofireobjectmapper.

tristanhimmelman avatar tristanhimmelman commented on June 18, 2024

ObjectMapper doesn't yet support specific error messaging when parsing errors occur. This is why this extension simply reports the same error.

@JayachandraA, looking at the sample you are trying to run, I can see the error by looking at the JSON response linked. You are trying to deserialize using data as a keypath but data isn't in the JSON response. Try again but omit the keypath.

from alamofireobjectmapper.

JayachandraA avatar JayachandraA commented on June 18, 2024

@tristanhimmelman @macbaszii thanks guys for your response. finally I found the solution.

from alamofireobjectmapper.

macbaszii avatar macbaszii commented on June 18, 2024

@JayachandraA What was your solution ? Could you share to us ?

from alamofireobjectmapper.

JayachandraA avatar JayachandraA commented on June 18, 2024

@macbaszii I just assigned empty values when I'm declaring optional properties
like this
var name: String? = ""
var desc: String? = ""
var coverURL: NSURL? = nil
var membersAmount: Int? = 0
var sportName: String? = ""

from alamofireobjectmapper.

BerkinSi avatar BerkinSi commented on June 18, 2024

@tristanhimmelman Hello I am having the same issue. I'll really appreciate if one can help me immediately, i really need a quick response.
Here is an example returning json
->
[
{
"eventdescription": "event2",
"participantid": "{7,2,3,NULL,NULL,NULL,NULL,NULL,NULL,NULL}",
"mainphotoid": 3,
"photosid": "{7,3,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL}",
"ownerid": 2,
"invitationlist": "{7,4,6,8,NULL,NULL,NULL,NULL,NULL,NULL}",
"privilligeId": "{7,3,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}",
"eventid": 2,
"eventdate": "2016-10-05 00:00:00",
"eventitle": "Come on first2"
},
{
"eventdescription": "asd",
"participantid": "{9,1,2,3,NULL,NULL,NULL,NULL,NULL,NULL}",
"mainphotoid": 2,
"photosid": "{1,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}",
"ownerid": 2,
"invitationlist": "{2,4,7,8,NULL,NULL,NULL,NULL,NULL,NULL}",
"privilligeId": "{1,2,3,NULL,NULL,NULL,NULL,NULL,NULL,NULL}",
"eventid": 3,
"eventdate": "2016-10-05 00:00:00",
"eventitle": "asdas"
},
{
"eventdescription": "UpdateasddddLet's starts",
"participantid": "{9,1,2,3,NULL,NULL,NULL,NULL,NULL,NULL}",
"mainphotoid": 2,
"photosid": "{1,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}",
"ownerid": 3,
"invitationlist": "{2,4,7,8,NULL,NULL,NULL,NULL,NULL,NULL}",
"privilligeId": "{1,2,3,NULL,NULL,NULL,NULL,NULL,NULL,NULL}",
"eventid": 4,
"eventdate": "2016-10-05 00:00:00",
"eventitle": "asdasd"
},
null,
null,
null,
null,
null,
null,
null
]
Here is my class to create mappable
->
screen shot 2016-06-15 at 03 52 21

I have set the initial values to nil regarding @JayachandraA 's solution. before setting them to nil, i gave them values of "" (if they are string), 0(if they are int), [""](string array), [0](int array)

This is my request
->

screen shot 2016-06-15 at 03 56 02

This is what i get when i print the responseString

Success: true
Response String: Optional("[{"eventdescription":"event2","participantid":"{7,2,3,NULL,NULL,NULL,NULL,NULL,NULL,NULL}","mainphotoid":3,"photosid":"{7,3,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL}","ownerid":2,"invitationlist":"{7,4,6,8,NULL,NULL,NULL,NULL,NULL,NULL}","privilligeId":"{7,3,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}","eventid":2,"eventdate":"2016-10-05 00:00:00","eventitle":"Come on first2"},{"eventdescription":"asd","participantid":"{9,1,2,3,NULL,NULL,NULL,NULL,NULL,NULL}","mainphotoid":2,"photosid":"{1,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}","ownerid":2,"invitationlist":"{2,4,7,8,NULL,NULL,NULL,NULL,NULL,NULL}","privilligeId":"{1,2,3,NULL,NULL,NULL,NULL,NULL,NULL,NULL}","eventid":3,"eventdate":"2016-10-05 00:00:00","eventitle":"asdas"},{"eventdescription":"UpdateasddddLet's starts","participantid":"{9,1,2,3,NULL,NULL,NULL,NULL,NULL,NULL}","mainphotoid":2,"photosid":"{1,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}","ownerid":3,"invitationlist":"{2,4,7,8,NULL,NULL,NULL,NULL,NULL,NULL}","privilligeId":"{1,2,3,NULL,NULL,NULL,NULL,NULL,NULL,NULL}","eventid":4,"eventdate":"2016-10-05 00:00:00","eventitle":"asdasd"},null,null,null,null,null,null,null]")

I am really desperate here i just hope that somebody can help me immediately

from alamofireobjectmapper.

BerkinSi avatar BerkinSi commented on June 18, 2024

I have used swiftyJson and could handle the nulls.

from alamofireobjectmapper.

Dr1992 avatar Dr1992 commented on June 18, 2024

Hello dude, Please help me.

URL (GET) - "https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/pulls?state=all"

image

image

image
...

Mapper below

image

I always got
image

from alamofireobjectmapper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.