Skip to content

Commit

Permalink
Revert "fix: Propagate node name for nested arrays" as it breaks back…
Browse files Browse the repository at this point in the history
…ward compatibility.

This reverts commit 5dc7803.
  • Loading branch information
srebhan committed Mar 21, 2024
1 parent 5dc7803 commit e425fbb
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 e425fbb

Please sign in to comment.