Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "fix: Propagate node name for nested arrays" as it breaks backward compatibility #19

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
}
Loading