Comments (9)
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.
@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.
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.
@tristanhimmelman @macbaszii thanks guys for your response. finally I found the solution.
from alamofireobjectmapper.
@JayachandraA What was your solution ? Could you share to us ?
from alamofireobjectmapper.
@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.
@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
->
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
->
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.
I have used swiftyJson and could handle the nulls.
from alamofireobjectmapper.
Hello dude, Please help me.
URL (GET) - "https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/pulls?state=all"
Mapper below
from alamofireobjectmapper.
Related Issues (20)
- Publish version 6.3.0 on CocoaPods HOT 3
- What is the compatible version with 'Alamofire', '~> 5.0.0-rc.3' ? HOT 6
- Ambiguous use of 'map(JSONObject:)' When migrating to swift 5 and using Xcode 11.2.1 HOT 25
- Giving error when install latest version through pod HOT 4
- Mapping dynamic response from API
- Swift Package Manager manifest HOT 4
- Can not able to install version 6.2.0 using cocopod HOT 2
- when do you plan to upgrade AlamofireObjectMapper to match the new Alamofire HOT 4
- AlamofireObjectMapper - Swift Compiler Error HOT 1
- Can Apple reject the App Store upload for using rc version of Alamofire?
- Memcpy Function
- Is this project still maintained ??? HOT 4
- Ambiguous use of 'mapArray(JSONObject:)'
- send array parameters
- compile error HOT 1
- it's still working ????? i am working on this but always show some error i don't no why
- can i change this line
- letest Alamofire version missmatched.
- Request for Alamofire Dependency Update to Support Privacy Manifest in AlamofireObjectMapper
- Request for Alamofire Dependency Update to Support Privacy Manifest in AlamofireObjectMapper SDK HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alamofireobjectmapper.