(path []string)
| 2850 | } |
| 2851 | |
| 2852 | func (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. |
no test coverage detected