JSON Tutorial - Marshal, Unmarshal, Struct Tags & Nested Data | Go Tutorial #23
11views
0011:36
T
Taught by Celeste AI - AI Coding Coach
View on YouTubeDescription
Learn how to work with JSON in Go! In this tutorial, we cover converting Go structs to JSON, parsing JSON into structs, using struct tags for field control, and handling nested JSON structures.
📚 What You'll Learn:
• json.Marshal - Convert Go structs to JSON bytes
• json.MarshalIndent - Create pretty-printed JSON
• json.Unmarshal - Parse JSON into Go structs
• Struct tags for custom field names
• omitempty to skip zero-value fields
• Exclude fields with json:"-"
• Nested JSON with embedded structs
⏱️ Timestamps:
0:00 - Introduction
0:28 - JSON Marshal (Struct to JSON)
2:46 - JSON Unmarshal (JSON to Struct)
5:07 - Struct Tags (Custom Field Names)
7:48 - Nested JSON Structures
10:47 - Recap & Key Takeaways
💻 Source Code:
https://github.com/GoCelesteAI/go_json
🔗 Key Functions Covered:
• json.Marshal() - Convert to JSON
• json.MarshalIndent() - Pretty print JSON
• json.Unmarshal() - Parse JSON
• Struct tags: `json:"name"`, `json:"name,omitempty"`, `json:"-"`
📖 Go Documentation:
• encoding/json: https://pkg.go.dev/encoding/json
▶️ Previous: Lesson 22 - File I/O
▶️ Next: Lesson 24 - Goroutines & Concurrency
#golang #go #programming #tutorial #json #api #coding #learntocode
Back to tutorialsOpen in YouTube
Duration
11:36
Published
February 3, 2026
Added to Codegiz
March 15, 2026