Expanding on Generic Json Parsing

Thu Apr 12 2018 | Mark Struzinski

Expanded JSON Parsing with Generics

In the last post, I went over a very simple way to use generics when parsing a small object that had a value type determined at runtime. Today, I’d like to expand on that concept a bit and show how I implemented that concept into a parent struct that contained arrays of this object.

Generic JSON Parsing

Mon Mar 26 2018 | Mark Struzinski

I have been working a lot in model layers lately. One benefit of this has been converting our older JSON parsing code over to using Swift 4’s enhanced JSON parsing capabilities. Using the Codable protocol has allowed me to delete hundreds of lines of boilerplate and streamline a lot of repetitive and error-prone code.

A lot of this work is pretty straightforward, where we are mapping properties to types, and sometimes including a CodingKey protocol object to ensure property names are mapped to JSON keys correctly. However, I ran across one interesting scenario and I wanted to share my solution to it.

I’ll present a simple generic object and its associated json in this post, and then show how that expanded out to a pretty nice solution once that smaller object became part of the full service in a future post.

CocoaConf Boston 2014

Sun Nov 16 2014 | Mark Struzinski

I attended the Boston stop of the CocoaConf tour this year. As always, it was a quality experience. I learned a ton, and I’m still processing all the valuable information that was crammed into my brain. The Klein family puts together a great mix of technical content, community interaction, and fun events.

Unit Testing Patterns for Asynchronous Networking Communications

Thu Oct 10 2013 | Mark Struzinski

A common issue I always run into is how to test asynchronous methods, especially networking calls. I used test the result of the calls, such as the parsing of return data, because testing the entire method proved impossible. I recently read an article from the excellent objc.io publication on asynchronous testing. By combining the patterns used in this article with some refactoring, I finally have my networking code under unit tests.

Here’s what I did:

A Change in Direction

Tue May 14 2013 | Mark Struzinski

In hitting brick walls, taking road trips for work, and feeling guilty about about posting in weeks, I have reconsidered the return on investment when fully implementing logic tests.

Previous Next