antchfx/jsonquery

Invalid xml output from OutputXML() when json is an array

Closed this issue · 1 comments

This code has json as an array [].

s := `[{"name":"John", "age":31, "female":false, "city":null}]`
doc, err := jsonquery.Parse(strings.NewReader(s))
if err != nil {
    panic(err)
}
fmt.Println(doc.OutputXML())

The code would produce this xml (added line breaks for clarity).

<?xml version="1.0" encoding="utf-8"?>
<root>
  <map[age:31 city:<nil> female:false name:John]>
    <age>31</age>
    <city><nil></city>
    <female>false</female>
    <name>John</name>
  </map[age:31 city:<nil> female:false name:John]>
</root>

As you can see the top element is a string representation of a map structure. The expected result could have an element with a bogus name like <element></element>.

fixed, thanks for feedback.