diff --git a/main.go b/main.go index 0c24aae..454e137 100644 --- a/main.go +++ b/main.go @@ -732,10 +732,7 @@ func (m *model) cursorPath() string { if at.key != nil { quoted := string(at.key) unquoted, err := strconv.Unquote(quoted) - if err != nil { - panic(err) - } - if identifier.MatchString(unquoted) { + if err == nil && identifier.MatchString(unquoted) { path = "." + unquoted + path } else { path = "[" + quoted + "]" + path diff --git a/node.go b/node.go index 3bd5998..eb90b62 100644 --- a/node.go +++ b/node.go @@ -177,10 +177,7 @@ func (n *node) paths(prefix string, paths *[]string, nodes *[]*node) { if it.key != nil { quoted := string(it.key) unquoted, err := strconv.Unquote(quoted) - if err != nil { - panic(err) - } - if identifier.MatchString(unquoted) { + if err == nil && identifier.MatchString(unquoted) { path = prefix + "." + unquoted } else { path = prefix + "[" + quoted + "]" @@ -218,11 +215,12 @@ func (n *node) children() ([]string, []*node) { for it != nil && it != n.end { if it.key != nil { - unquoted, err := strconv.Unquote(string(it.key)) - if err != nil { - panic(err) + key := string(it.key) + unquoted, err := strconv.Unquote(key) + if err == nil { + key = unquoted } - paths = append(paths, unquoted) + paths = append(paths, key) nodes = append(nodes, it) }