“Swift is supposed to be easy to learn and use. So why am I stuck trying to get a simple JSON parser to work?”

You start your day all fired up to get your app running with live data from your JSON API, but before you know it the day is over and you’ve barely made any progress. Your Xcode console displays just one line of output: a single string you managed to pull out of the JSON that serves as an indicator of how little you accomplished today. Rather than making you more productive, Swift is preventing you from getting anything done. In front of you lies a mess of code that’s littered with nested conditionals, and your app still crashes when you try to pull out other values. And you haven’t even started the part where you deserialize the JSON into model objects you can actually use in your app.

Does it really take this much work to parse a simple JSON object, or are you doing it wrong?

What if you could run your app with JSON from the API today?

Imagine this: you start your day all fired up to get your app running with live data from your JSON API. Before you know it, you’ve deserialized your JSON into model objects you can use in your app. Xcode shows a suite of passing tests: a clear indication of all the progress you’ve made. You’re proud of the work you’ve done and confident your app can handle any JSON the API returns. As you head to lunch, you can’t help but smile as you think about how much you got done this morning.

Deserializing JSON in Swift can make you feel like you’re wrestling the compiler, but you don’t have to let it beat you.

Great news: you can build a simple JSON parser in Swift without sinking the next three days into it

Parsing JSON in Swift will teach you to harness the power of Swift and give you confidence that your app can gracefully handle any JSON that comes its way.

  • You’ll learn:

    • How to use NSJSONSerialization to transform JSON into Swift types, and why you should avoid using AnyObject whenever you can
    • The dangers of forced type casting
    • Simple strategies you can use to make your JSON deserialization more concise, readable, and elegant
    • Whether to return nil, empty, or throw an error when transforming JSON into an array of model objects
    • How to write unit tests to increase your confidence in your parser’s correctness
  • Cover-400x600

You’ll go from fighting an uphill battle against an uncooperative compiler to having a JSON parser that’s proven to be stable with automated tests. Here’s what’s in the book:

Convert JSON into Swift types with NSJSONSerialization
  • Deserializing JSON into Swift types
  • The dangers of forced type casting
  • Where should all this JSON code go?
  • Handling errors with do-try-catch

Get this section for free!

Increase your confidence with automated tests
  • Why test?
  • Creating a JSON test file
  • Creating a JSON test case
  • Dealing with test failures
  • Increasing confidence with test coverage
  • Enabling and viewing test coverage reports in Xcode
  • Avoiding false confidence with strong assertions
  • Testing the error path
  • Finding the point of diminishing returns
Achieve conciseness, readability, and elegance with these simple principles
  • Reducing clutter with proper typing
  • Increasing clarity and readability with typealias
  • Deconstructing the pyramid of doom
Transform Swift types into model objects for convenience and stability
  • Why model objects?
  • Testing with model objects
  • Creating a model object
  • Transforming dictionaries into model objects
  • Producing specific error messages to clarify where parsing failed
  • Handling arrays and nil

If you follow the patterns and principles in Parsing JSON in Swift, you’ll be confident that your app can gracefully handle any JSON your API might return.


The Expanded Edition

  • PDF of Parsing JSON in Swift
  • The source code for the Repos app so you can see how to apply the concepts in the book to your own project
  • Checklist: Questions to ask before adding a third party framework to your app
With the source code for the Repos app, you’ll be able to copy and paste into your own project to start making progress today. And the checklist will give you guidance if you’re considering — or already using — popular third-party frameworks like Alamofire and SwiftyJSON.

Start Parsing JSON in Swift today. Buy the Expanded Edition for $49

Want to share with your team?

Get a team license and share the book, source code, and checklist — everything in the Expanded Edition — with up to 10 people so your team can be more productive.

Purchase a team license for $199


The Strategy Edition

Includes everything in the Expanded Edition plus a one-on-one call with me to make sure you can immediately apply what you learn to your project.

  • PDF of Parsing JSON in Swift
  • The source code for the Repos app so you can see how to apply the concepts in the book to your own project
  • Checklist: Questions to ask before adding a third party framework to your app
  • A private one hour consultation with me where you can get help parsing your JSON in your app

On top of the book, checklist, and source code, you can spend an hour with me to make sure you don’t waste days stuck on a problem as you start parsing JSON in Swift in your project. This is the fastest way to getting started in the right direction and the best way to make sure you stay on track.

Start Parsing JSON in Swift today. Buy the Strategy Edition for $169


The Basic Edition

  • PDF of Parsing JSON in Swift
If you’re confident you can implement the concepts in the book on your own, this edition is for you.

Start Parsing JSON in Swift today. Buy the Basic Edition for $29


Is Parsing JSON in Swift right for me?

If you can fetch JSON data from your API but you’re frustrated with trying to parse it, this book is for you. It’ll show you how to transform your JSON into model objects you can use in your app – and it’ll give you confidence that your parser can handle both expected and unexpected data.

If you’re still trying to figure out how to make HTTP requests and get data from your API, you won’t find that here. There are already plenty of tutorials out there to teach you networking in Swift – I’d recommend searching to find one that can help.

But maybe after getting the data from your API, you’re frustrated with the verbose, tangled mess of code that seems to be required to convert JSON into model objects. If you feel like there must be a better way to parse JSON in Swift, this book is written for you.

If you’re still not sure, email josh@roadfiresoftware.com with any questions and I’d be happy to help.

What are people saying?

“I have been running around my office like a wild woman, grabbing people by the lapels and shouting typealias JSONDictionary = [String: AnyObject] like Scrooge on Christmas morning. It has changed my life for the better. I may get a tattoo.” — Anne Cahalan
“The major lesson I learned from it is, that I don’t need to rely on any 3rd party library to parse JSON securely and efficiently.” — Stefan Jager

What format does the book come in?

You can download Parsing JSON in Swift as a PDF.

If I buy the Basic or Expanded Edition now, can I upgrade later for the difference?

Yes! Send me an email and I’ll help you upgrade to the package you want.

What if I’m not happy with the book?

I want you to be happy with it, so if for some reason you’re not, just send me an email and I’ll give you a refund as soon as I can.


The Expanded Edition

  • PDF of Parsing JSON in Swift
  • The source code for the Repos app so you can see how to apply the concepts in the book to your own project
  • Checklist: Questions to ask before adding a third party framework to your app
With the source code for the Repos app, you’ll be able to copy and paste into your own project to start making progress today. And the checklist will give you guidance if you’re considering — or already using — popular third-party frameworks like Alamofire and SwiftyJSON.

Start Parsing JSON in Swift today. Buy the Expanded Edition for $49

Want to share with your team?

Get a team license and share the book, source code, and checklist — everything in the Expanded Edition — with up to 10 people so your team can be more productive.

Purchase a team license for $199


The Strategy Edition

Includes everything in the Expanded Edition plus a one-on-one call with me to make sure you can immediately apply what you learn to your project.

  • PDF of Parsing JSON in Swift
  • The source code for the Repos app so you can see how to apply the concepts in the book to your own project
  • Checklist: Questions to ask before adding a third party framework to your app
  • A private one hour consultation with me where you can get help parsing your JSON in your app

On top of the book, checklist, and source code, you can spend an hour with me to make sure you don’t waste days stuck on a problem as you start parsing JSON in Swift in your project. This is the fastest way to getting started in the right direction and the best way to make sure you stay on track.

Start Parsing JSON in Swift today. Buy the Strategy Edition for $169


The Basic Edition

  • PDF of Parsing JSON in Swift
If you’re confident you can implement the concepts in the book on your own, this edition is for you.

Start Parsing JSON in Swift today. Buy the Basic Edition for $29


Can I try a free sample?

Absolutely you can! Grab your free sample and start Parsing JSON in Swift today.

What version of Swift is this written for?

The code in the book is written in Swift 3, so if you’re using Swift 2, you’ll have a few minor syntax changes to work through, but the principles apply just the same.

Who’s the author?

Hi, I’m Josh Brown. I’ve been developing for iOS since 2009 and teaching it for just as long. These days, I get to help people learn iOS every day through my workshops, video courses, this book, and my blog. I love seeing what people learn and do with their new knowledge and skills, so if you use anything I’ve written or recorded to build something cool, I’d love to hear from you — just send me an email and tell me about it.

In addition to teaching, I also enjoy building apps, which is how I got into iOS in the first place. I was tired of building software I couldn’t really show or explain to my friends and family. I love that now I can pull my iPhone out and show them what I built and say “I made this.”

Most recently, I’ve been contributing to the Swift open source project, writing this book, and helping my clients refactor their code and track down crashes.

I have another question.

Send it my way and I’d be happy to answer it.