Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

JSON property sometimes is a numeric value and sometimes a string value #8

Closed
patricks opened this issue Jul 10, 2018 · 2 comments
Closed
Labels

Comments

@patricks
Copy link

Hi,

I have a special case, I have a JSON response which sometimes returns a numeric value and sometimes a string value for the same key. Is there any way to handle such a JSON response.

I know, that this isn't a good idea in general, but I don't have access to the server backend 😉.

@Otbivnoe
Copy link
Owner

Otbivnoe commented Jul 10, 2018

Hey @patricks! Have you tried to implement custom decode logic via init(from decoder: Decoder) of Decodable. I think it's the most preferable way to handle your situation. 🤔

@patricks
Copy link
Author

Thanks that fixes my problem.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants