Last active
May 25, 2023 05:23
-
-
Save nikzayn/6aab5c30abdc6b04c20c14976b8f2b8a to your computer and use it in GitHub Desktop.
Example to show the output of json without using omitempty tag
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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