jsonPathRemove function
Remove the value at path from root. Returns the (possibly mutated)
root.
Implementation
Object? jsonPathRemove(Object? root, String path) {
if (path == r'$') return null;
final parent = _jsonPathParent(root, path);
if (parent == null) return root;
final c = parent.container;
final k = parent.key;
if (c is Map) {
c.remove(k);
} else if (c is List) {
final idx = k as int;
if (idx >= 0 && idx < c.length) c.removeAt(idx);
}
return root;
}