Edge case for XML conversion
Closed this issue · 1 comments
arcanechimp commented
When converting from XML to a map I have found that a string value of "NAN", gets cast to a float value as a NaN. This is not the desired result in this particular case, as it is actually a string value.
There is no NaN equivalent in JSON, so when converting from a Map to JSON, I get an error:
json: unsupported value: NaN
I assume this issue would also arise if there was a string value of "Inf" or "-Inf".
I have written a small example below to replicate the issue.
package main
import (
"fmt"
"github.com/clbanning/mxj"
)
func main() {
var xml = []byte("<foo><bar>NAN</bar></foo>")
m, err := mxj.NewMapXml(xml, true)
if err != nil {
panic(err)
}
fmt.Print(m.StringIndent())
fmt.Println()
j, err := m.JsonIndent("", " ", true)
if err != nil {
panic(err)
}
fmt.Print(string(j))
}
clbanning commented
patched. thanks.