MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / doRemovePath

Method doRemovePath

pkg/util/json/json.go:1755–1782  ·  view source on GitHub ↗
(path []string)

Source from the content-addressed store, hash-verified

1753}
1754
1755func (j jsonObject) doRemovePath(path []string) (JSON, bool, error) {
1756 if len(path) == 0 {
1757 return j, false, nil
1758 }
1759 if len(path) == 1 {
1760 return j.RemoveString(path[0])
1761 }
1762 idx, ok := findPairIndexByKey(j, path[0])
1763 if !ok {
1764 return j, false, nil
1765 }
1766
1767 newVal, ok, err := j[idx].v.doRemovePath(path[1:])
1768 if err != nil {
1769 return nil, false, err
1770 }
1771 if !ok {
1772 return j, false, nil
1773 }
1774
1775 result := make(jsonObject, len(j))
1776 for i := range j {
1777 result[i] = j[i]
1778 }
1779 result[idx].v = newVal
1780
1781 return result, true, nil
1782}
1783
1784// When we hit a scalar, we stop. #- only errors if there's a scalar at the
1785// very top level.

Callers 1

RemovePathMethod · 0.95

Calls 3

RemoveStringMethod · 0.95
findPairIndexByKeyFunction · 0.85
doRemovePathMethod · 0.65

Tested by

no test coverage detected