SwiftUI Tutorial — How to Read a JSON File

Use JSON and MapKit in SwiftUI

Ale Patrón
3 min readNov 24, 2021

Note: This tutorial is also available in video form on YouTube.

In this tutorial, we’re going to use Swift and SwiftUI to build an app that reads a JSON file and uses its contents to display annotations on a map using MapKit.

After creating a new Xcode project that uses SwiftUI for the interface, we will start by adding the JSON file to our project. I created a JSON file that you can download here. This file includes a list of locations, each with an id, a name, a latitude, and a longitude, as seen below.

To add the JSON file to your project, you can just drag and drop it inside Xcode:

--

--

No responses yet