From the course: Consuming RESTful APIs in Golang
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Parsing JSON responses - Go Tutorial
From the course: Consuming RESTful APIs in Golang
Parsing JSON responses
- [Instructor] Earlier we briefly looked at marshalling structs into JSON to be sent as request bodies in our HTTP clients. But now we are looking to go the other way round, which is unmarshalling responses from APIs in JSON format into Golang structs or data structures. What's unmarshalling, you will say? Unmarshalling is the process of converting JSON data into a Golang data structure. Let's start with a simple example in our coding environment. Let's try and unmarshal a JSON response using a struct, and let's slowly complicate it further. So let's head on over to the coding environment. The first example we want to look at is a very simple example. In this example, we will be making a request to fetch information from a remote server and convert the response which is coming in JSON format, converting that response into a Golang struct. The first thing you want to do is, of course, as usual, specify your imports. And in this video, the only new package you're being exposed to is…