I was happy to see that the idea of using nothing
to indicate removing an entry was removed from the PR #25697, which would have broken a lot of code (we used nothing
to indicate JSON null
), and I think there is a cleaner way that the functionality of being able to also remove items in a non-breaking fashion.
Now that replacements are done using Pair
s, i.e. key => value
, a wrapper type could be constructed to indicate that the key is to be removed instead, i.e. Delete(key)
(struct Delete ; val::Any ; end
), in a similar fashion that OccursIn
and EqualsTo
are used to wrap values for the find*
functions now.
1 Like
Sounds like a good possible alternative to the other ideas (mentioned in the PR). Out of curiosity, do you have a use case for this functionality? This would help motivate updating the API. Would it be more for convenience or efficiency (one pass instead of replace
+filter
) ?
I don’t have a use case right at the moment, it’s mainly for efficiency, and to have the same sort of functionality present with replace on a string (where you can remove a character or substring in a string using “”).
In the past, I have needed this sort of functionality, that I had to code in C .
There’s no rush though, since with this approach, it isn’t breaking change, it could be added at any time (like for v1.1)
I just wanted to make sure that people were aware that there was a simpler alternative for the API, if this functionality was desired in replace
.