Answers for "go change json key struct"

Go
0

go change json key struct

type Person struct {
  Name string `json:"person_name"`
  Surname string `json:"person_surname"`
}

func main(){
  Bytes, err := json.Marshal(Person{"Joe", "Soap"})
  if err != nil {
    log.Fatal(err.Error())
  }
  fmt.Println(string(Bytes))
}
Posted by: Guest on June-12-2020

Browse Popular Code Answers by Language