Skip to content

Commit

Permalink
Merge branch '#19'
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengchun committed Mar 22, 2024
2 parents 4a81131 + e425fbb commit f8be7d5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 23 deletions.
2 changes: 1 addition & 1 deletion node.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func parseValue(x interface{}, top *Node, level int) {
case []interface{}:
// JSON array
for _, vv := range v {
n := &Node{Data: top.Data, Type: ElementNode, level: level, value: vv}
n := &Node{Type: ElementNode, level: level, value: vv}
addNode(n)
parseValue(vv, n, level+1)
}
Expand Down
22 changes: 0 additions & 22 deletions node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,25 +133,3 @@ func TestLargeFloat(t *testing.T) {
t.Fatalf("expected %v but %v", "365823929453", n.InnerText())
}
}

func TestNestedArray(t *testing.T) {
s := `{
"values": [
[
1,
2,
3
]
]
}`
doc, err := parseString(s)
if err != nil {
t.Fatal(err)
}

expected := `<?xml version="1.0" encoding="utf-8"?><root><values><values>1</values><values>2</values><values>3</values></values></root>`
xml := doc.OutputXML()
if xml != expected {
t.Fatalf("expected %q but got %q", expected, xml)
}
}

0 comments on commit f8be7d5

Please sign in to comment.