How to create set a variable in a Struct in swift that conforms to Decodable and Encodable protocol? : <p>I'm fetching data from an API but this API has a small problem inside location JSON Object, it contains a variable called <code>postcode</code> and this variable can be either a <code>String</code> or a <code>Int</code>.</p>

<p>I have to handle this problem locally, If I set <code>var postcode: String</code> I get an error when this value is  <code>Int</code> and if I set <code>var postcode: Int</code> I get an error when this value is a <code>String</code></p>

<p>so I tried to set <code>var postcode: Any</code> but the following problem occurs...</p>

<p><a href="https://i.stack.imgur.com/RN85r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RN85r.png" alt="enter image description here"></a></p>

<p>it when I set this value it doesn't conform to Codable protocol...</p>

<p>when I return the way it was before....</p>

<p><a href="https://i.stack.imgur.com/RTFmP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RTFmP.png" alt="enter image description here"></a></p>

<p>I got no errors BUT it doesn't handle my problem with the API.</p>

<p>what am I missing here?</p>

<p>thank you in advance for the answers..</p>
