Closed aravasio closed 7 years ago
@aravasio I created a unit test for your situation and I cannot reproduce. See commit: https://github.com/sean7512/RestEssentials/commit/4253b19acb76609a119c9c233f608b84e1b2ae1c
You can even change error_code to 02
on the post and it still succeeds. So httpbin will just respond back with the same data that was posted to it. It looks as if your number 2 is a string. The server isn't sending it as a string, is it? If it has quotes around it, then you will absolutely see the issue you have above.
Even so, if you are using Swift 4, I would highly recommend using the Codable protocol and stop parsing raw json manually, Codable is a much safer solution.
Yeah, you're right. I don't know where I got the Postman info, but now it definitely shows a "02" for that value, making it a string.
You can close this. It's clear it's a misunderstanding on our side about how API works, not the library.
Thanks
Ok, this is super weird and, as far as I understand it, it's hard to believe I did not come across this sooner.
Given the following JSON
if I evaluate as such:
it will not enter, since the .int evaluation will return nil. It seems the issue is in the
numerical
eval,Printing those same cases gives the following results:
Any ideas on what might be causing this?
It might be worth noting that
"error_code" : 2
on the actual server response, for some reason during conversions and passing, RestEssentials seems to convert it to02
, but on postman it's just2
. No idea how relevant this might be, but I'm putting this out there.