We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
https://play.golang.org/p/1Wv3nOtX1CC
package main import ( "bytes" "encoding/json" "fmt" "github.com/jinzhu/copier" ) type mySubStruct struct { Val6 *string Val7 *string } type myStruct struct { Val1 *string Val2 *string Val3 *string Val4 map[string]mySubStruct Val5 map[string]*string Val8 *string } func main() { var err error m1 := new(myStruct) v1 := []byte(`{ "val1":"####", "val2":null, "val3":"Tres", "val4":{ "test":{ "val6":"####", "val7":"Cinco" } }, "val8":"Siete" }`) err = json.NewDecoder(bytes.NewReader(v1)).Decode(m1) if err != nil { panic(err) } m2 := new(myStruct) v2 := []byte(`{ "val1":"Uno", "val2":"Dos", "val4":{ "test":{ "val6":"Cuatro" } }, "val5":{ "left":"Seis" }, "val8":null }`) err = json.NewDecoder(bytes.NewReader(v2)).Decode(m2) if err != nil { panic(err) } err = copier.CopyWithOption(m1, m2, copier.Option{IgnoreEmpty: true, DeepCopy: true}) b, _ := json.Marshal(m1) fmt.Println("Result\t", string(b)) fmt.Println("Expected", `{"val1":"Uno","val2":"Dos","val3":"Tres","val4":{"test":{"val6":"Cuatro","val7":"Cinco"}},"val5":{"left":"Seis"}},"val8":"Siete"`) }
The text was updated successfully, but these errors were encountered:
jinzhu
No branches or pull requests
https://play.golang.org/p/1Wv3nOtX1CC
The text was updated successfully, but these errors were encountered: