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

Method doRemovePath

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

Source from the content-addressed store, hash-verified

2850}
2851
2852func (j jsonObject) doRemovePath(path []string) (JSON, bool, error) {
2853 if len(path) == 0 {
2854 return j, false, nil
2855 }
2856 if len(path) == 1 {
2857 return j.RemoveString(path[0])
2858 }
2859 idx, ok := findPairIndexByKey(j, path[0])
2860 if !ok {
2861 return j, false, nil
2862 }
2863
2864 newVal, ok, err := j[idx].v.doRemovePath(path[1:])
2865 if err != nil {
2866 return nil, false, err
2867 }
2868 if !ok {
2869 return j, false, nil
2870 }
2871
2872 result := make(jsonObject, len(j))
2873 copy(result, j)
2874 result[idx].v = newVal
2875
2876 return result, true, nil
2877}
2878
2879// When we hit a scalar, we stop. #- only errors if there's a scalar at the
2880// 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