← All Exercises

Struct Tags for JSON

basicgo~10min

Background

Struct tags configure serialization without changing the struct field names in Go code.

Problem

Define a struct with JSON tags for custom field naming and optional field omission.

Input

A struct with tags

Output

JSON with custom field names

Sample tests

Sample 1

Input: struct with json tags
Expected: custom JSON output

Your solution

Learning objective

Learn struct metadata and serialization control