Skip to content

Instantly share code, notes, and snippets.

@nikzayn
Last active May 25, 2023 05:23
Show Gist options
  • Save nikzayn/6aab5c30abdc6b04c20c14976b8f2b8a to your computer and use it in GitHub Desktop.
Save nikzayn/6aab5c30abdc6b04c20c14976b8f2b8a to your computer and use it in GitHub Desktop.
Example to show the output of json without using omitempty tag
package main
type Person struct {
Name string
Age int
}
func main() {
p := Person{
Name: "Nikhil",
}
b, _ := json.Marshal(p)
fmt.Println(string(p))
}
// Output
- {"Name":"Nikhil","Age":0}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment