JSON
{
"name": "John Doe",
"age": 30,
"city": "New York"
}type Person struct {
Name string `json:"name"`
Age int `json:"age"`
City string `json:"city"`
}person := Person{Name: "John Doe", Age: 30, City: "New York"}
jsonData, err := json.Marshal(person)
if err != nil {
fmt.Println("Error encoding JSON:", err)
}
fmt.Println(string(jsonData)) // {"name":"John Doe","age":30,"city":"New York"}Last updated