title: How to correctly serialize embedded struct with String() method to JSON string?
body: <pre><code> package main
  
   import (
      "fmt"
      "encoding/json"
   )
  
   type Ticket struct {
      From string
      To   string
  }
  
  func (t Ticket) String() string {
      return fmt.Sprintf("%s - %s", t.From, t.To)
  }
  
  type Passenger struct {
      Name string `json:"Name"`
      Tkt  Ticket `json:"Ticket"`
  }
  
  func main() {
      p := Passenger{}
      p.Name = "John"
      p.Tkt.From = "New York"
      p.Tkt.To = "Washington"
  
      buf, _ := json.Marshal(p)
      fmt.Println(string(buf))
  }
  </code></pre>
  
  <p>This code outputs:</p>
  
  <pre><code> {"Name":"John","Ticket":{"From":"New York","To":"Washington"}}
  </code></pre>
  
  <p>But, using <code>json.Marshal()</code> method (it's easy and friendly for complex struct), how to make it output like this:</p>
  
  <pre><code> {"Name":"John","Ticket":"New York - Washington"}
  </code></pre>