mattpolzin / JSONAPI

Swift Codable JSON:API framework
MIT License
75 stars 19 forks source link

How can I parse an Attribute which is a JSON object #96

Closed sterien7 closed 2 years ago

sterien7 commented 2 years ago

My struct has a property which has a value of a JSON object. In this object there are always different data so there is no exact structure, so there is no way to create a parser for it as I dont know the properties of each JSON object. So my question is show can I have an Attribute to this. I tried to make it a dictionary from String to Any but this is not working. Do you have any suggestion?

mattpolzin commented 2 years ago

Good question! I like to use the AnyCodable library when I need to parse a structure of unknown shape as a Codable type (as required by this library's JSON:API Attributes).

I could say a bit more on the subject, just let me know if this gets you what you need!

mattpolzin commented 2 years ago

I'm going to close this question assuming my answer addressed it; please reopen the issue if you want to ask any follow-up questions!