diff --git a/gentests/_testgen/testgen.go b/gentests/_testgen/testgen.go index 8ceb31f..6941ee2 100644 --- a/gentests/_testgen/testgen.go +++ b/gentests/_testgen/testgen.go @@ -118,7 +118,7 @@ func genXSDTests(cfg xsdgen.Config, data []byte, pkg string) (code, tests *ast.F fields = append(fields, gen.Public(elem.Name.Local), ast.NewIdent(main.NameOf(elem.Type)), - gen.String(fmt.Sprintf(`xml:"%s %s"`, elem.Name.Space, elem.Name.Local))) + gen.String(fmt.Sprintf(`json:"%s" xml:"%s %s"`, elem.Name.Local, elem.Name.Space, elem.Name.Local))) } expr, err := gen.ToString(gen.Struct(fields...)) if err != nil { diff --git a/xsdgen/xsdgen.go b/xsdgen/xsdgen.go index bf705d7..0ceb176 100644 --- a/xsdgen/xsdgen.go +++ b/xsdgen/xsdgen.go @@ -684,7 +684,7 @@ func (cfg *Config) genComplexType(t *xsd.ComplexType) ([]spec, error) { if el.Nillable || el.Optional { options = ",omitempty" } - tag := fmt.Sprintf(`xml:"%s %s%s"`, el.Name.Space, el.Name.Local, options) + tag := fmt.Sprintf(`json:"%s%s" xml:"%s %s%s"`, el.Name.Local, options, el.Name.Space, el.Name.Local, options) base, err := cfg.expr(el.Type) if err != nil { return nil, fmt.Errorf("%s element %s: %v", t.Name.Local, el.Name.Local, err) @@ -743,6 +743,7 @@ func (cfg *Config) genComplexType(t *xsd.ComplexType) ([]spec, error) { } else { tag = fmt.Sprintf(`xml:"%s,attr%s"`, attr.Name.Local, options) } + tag = fmt.Sprintf(`json:"%s%s" %s`, attr.Name.Local, options, tag) base, err := cfg.expr(attr.Type) if err != nil { return nil, fmt.Errorf("%s attribute %s: %v", t.Name.Local, attr.Name.Local, err)