嵌入struct但在json中仅包含某些字段

I have a struct that I want to embed but want to json encode only certain fields of that struct (and lowercase them). Is that possible?

https://play.golang.org/p/bEC4zlx2oC:

package main

import (
    "encoding/json"
    "fmt"
    "net/url"
)

type MyStruct struct {
    Name string `json:"name"`
    *url.URL
}

func main() {
    m := &MyStruct{
        "Bob",
        &url.URL{
            Scheme: "http", 
        },
    }

    j, err := json.Marshal(m)
    if err != nil {
        fmt.Println(err)
    }
    fmt.Println(string(j))  // want {"name":"Bob","scheme":"http"}
}

Expanding my comment with example.

It is feasible, you have to implement Marshal interface.

For example:

func (u *MyStruct) MarshalJSON() ([]byte, error) {
    return json.Marshal(&struct {
        Name   string `json:"name"`
        Scheme string `json:"scheme"`
    }{
        Name:   u.Name,
        Scheme: u.Scheme,
    })
}

Play Link: https://play.golang.org/p/LLchuOdYvf

Output:

{"name":"Bob","scheme":"http"}