MCPcopy Create free account
hub / github.com/dolthub/doltgresql / doRemovePath

Method doRemovePath

postgres/parser/json/json.go:1830–1855  ·  view source on GitHub ↗
(path []string)

Source from the content-addressed store, hash-verified

1828}
1829
1830func (j jsonObject) doRemovePath(path []string) (JSON, bool, error) {
1831 if len(path) == 0 {
1832 return j, false, nil
1833 }
1834 if len(path) == 1 {
1835 return j.RemoveString(path[0])
1836 }
1837 idx, ok := findPairIndexByKey(j, path[0])
1838 if !ok {
1839 return j, false, nil
1840 }
1841
1842 newVal, ok, err := j[idx].v.doRemovePath(path[1:])
1843 if err != nil {
1844 return nil, false, err
1845 }
1846 if !ok {
1847 return j, false, nil
1848 }
1849
1850 result := make(jsonObject, len(j))
1851 copy(result, j)
1852 result[idx].v = newVal
1853
1854 return result, true, nil
1855}
1856
1857// When we hit a scalar, we stop. #- only errors if there's a scalar at the
1858// 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