From e425fbb9e645b0f3d81ee773eb68c923ec5dc7cc Mon Sep 17 00:00:00 2001 From: Sven Rebhan Date: Thu, 21 Mar 2024 15:29:09 +0100 Subject: [PATCH] Revert "fix: Propagate node name for nested arrays" as it breaks backward compatibility. This reverts commit 5dc78031b1e01ea46098b6717d6fed5abcea7994. --- node.go | 2 +- node_test.go | 22 ---------------------- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/node.go b/node.go index 95f8e08..4891810 100644 --- a/node.go +++ b/node.go @@ -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) } diff --git a/node_test.go b/node_test.go index 6dd0af8..f4b968a 100644 --- a/node_test.go +++ b/node_test.go @@ -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 := `123` - xml := doc.OutputXML() - if xml != expected { - t.Fatalf("expected %q but got %q", expected, xml) - } -}