(path []string)
| 1828 | } |
| 1829 | |
| 1830 | func (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. |
no test coverage detected