tailor returns only the map of the specified keys
go get github.com/wandercn/tailor
package main
import (
"fmt"
"github.com/wandercn/tailor"
)
func main() {
doc := tailor.Object{
"A": 1,
"B": tailor.Object{
"age": 20},
"C": "c",
"D": 0.99,
}
fmt.Printf("before: %v\n", doc)
keys := []string{"C", "D"}
result := tailor.ClipOne(keys, doc)
fmt.Printf("after: %v\n", result)
}
before: map[A:1 B:map[age:20] C:c D:0.99]
after: map[C:c D:0.99]