Conversion from a null element to <element/> is broken
Closed this issue · 2 comments
Cruiser79 commented
I got the following example
package main
import (
"github.com/clbanning/mxj"
"encoding/json"
"fmt"
"bytes"
)
func main() {
var data = `{"lastname":"Mustermann","phone": null}"`
mxj.JsonUseNumber = true
var x interface{}
dec := json.NewDecoder(bytes.NewReader([]byte(data)))
dec.UseNumber()
if err := dec.Decode(&x); err != nil {
fmt.Printf("Unmarshal: %v", err)
}
xx, err := mxj.AnyXmlIndent(x, "", " ", "body")
if err != nil {
fmt.Println(err)
}
fmt.Println(string(xx))
}
Expected result is an empty phone element
<body>
<lastname>Mustermann</lastname>
<phone/>
</body>
This is working in commit 1db1a88
but broken from commit adfeeb9
From this commit up to current master, we got this result
<body>
<lastname>Mustermann</lastname>
<phone
</body>
clbanning commented
Fixed on tip.
Cruiser79 commented
Wow, thx, quick fix. Now it is working.