-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding support for empty paths #397
Conversation
@phochste wouldn't it be better to make this new behaviour optional? For example by adding an extra option? |
I doubt that anyone wants the current behaviour as it raises warnings and results in a null operation:
|
@nichtich those warnings are the result of comparing strings and undefined keys with each other. That is a totally different issue (which should be fixed too). The current vacuum clears "empty" values. This PR deletes values when the keys are considered empty. What if someone accidentally puts useful information in an empty key? Just delete it? Why not create a separate fix |
@nicolasfranck This pull request is not about the As far as I know, in all fixes path are written at design time. It is the creator of a fix that writes a path. I can't imagine a writer of a fix will write a JSON-path and expects it always to result in a null operation. I should make an issue out of this. The behavior in current Catmandu is weird. For some operations empty fields seem to be supported by obviously it is a bug.
The There are still some open issues however I notice today. Even with the current pull request only empty fields at root level can be addressed. For instance it is not possible to generate a document like the one below with only
|
@phochste right.. btw I thought that empty paths where equal to the root (which can also be written as a "dot")? |
The empty path seems indeed to be reserved for pointing to the root of the JSON hash. The update of the pull requests introduces empty paths explicitly (and support for nested empty paths):
|
@phochste we should also handle double quotes |
Adding support for empty paths in fixes.
E.g.
should give