(path []string)
| 1753 | } |
| 1754 | |
| 1755 | func (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. |
no test coverage detected