I am working with NASA's Near Earth Object Web Service to retrieve data to be displayed in an application. I understand how to use Swift 4's Codable
protocol, but I do not understand how to map part of the response.
Using Paw, I inspected the response from the API:
As you can see, the near_earth_objects
structure is a Dictionary
, and the keys are dates. The issue is that the URL parameters are dates, so these date structures will change, depending on the day of the request. Therefore, I do not know how I can create properties to be automatically mapped when using the Codable
protocol.
The data that I am trying to get to inside of these structures are Array
s that contain Dictionary
s:
How can I have my model object conform to the Codable
protocol and map these structures when the dates will change as the dates of the requests change?