Join David Gassner for an in-depth discussion in this video Creating and parsing a JSON string, part of Learning Go.
- When make you make a request to a web service,…the data frequently comes back in JSON format.…Go has a JSON package that lets you easily create…and read JSON formatted text.…I'll demonstrate parsing JSON in this example.…In this file, parseJSON.go, I still have the same code…from a previous exercise, but I've restructured it a bit.…My main function still declares the URL,…the source of my JSON data,…but then all the code that's making the request…from the server, has been placed into a separate function,…named "contentFromServer".…
It makes the request,…and then returns the content as a string.…Then, in my main function,…I'm just dumping that content to the console.…I'll go to a command prompt, and run that code.…And show that it's succeeding in getting the data…from the server, but I'm just getting…a big old blob of text.…My job now is to parse that text,…and turn it into structured data…that I can use in my application.…My first task is to define a custom type.…
A struct, that will represent each entity…within my JSON data.…
- Installing Go tools
- Creating and compiling a Go workspace
- Exploring variables, constants, and types
- Storing ordered and unordered values
- Grouping related values in structs
- Programming conditional logic and loops
- Defining and calling functions
- Handling errors
- Working with files
- Creating a simple HTTP server
Skill Level Beginner
1. Getting Started
2. Essential Go Skills
3. Managing Simple Values
4. Managing Complex Types and Collections
5. Managing Program Flow
6. Structuring Go Code
7. Working with Files and the Web
Next steps2m 26s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.