Reading a Date type from a JSON file

Hey All,

I have been combing the inter-webs looking for an answer to this question. Thus far no luck.

I have a VERY long JSON file that I need to find a day on based on today’s date. There are no dates in the JSON, just weeks of the year.

What I thought of doing is adding a weekOfYear to the JSON, and provide the number of the week.

I have a Calendar method that provides me the .weekOfYear based on a specific date but it returns a Date type.

So finally to my question. If I add the “47” to the JSON and add var weekOfYear:Date! to my model; when Swift creates the array from the JSON, will it be a Date type?

I then need to loop through the array to find the week based on this Date number in the JSON, then I can find the day, as I have a different method to return today’s day.

Make sense?

Thanks for any ideas you can send my way.

Blessings,
—Mark

Oh my, sometimes I make things so hard.

No need for a Date type, since all the JSON types are Strings, if it easy to add another String and convert it to an Int in the code and make the comparison.

So simple…lesson learned? Walk away and look at the problem with fresh eyes later!

Blessings,
—Mark

Haha yes leaving then coming back to a problem is more effective than you’d think :slight_smile: