-
Notifications
You must be signed in to change notification settings - Fork 58
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
Quoted keys shouldn't need the quotes #33
Comments
I would argue that the quotes are part of the key. What in the spec makes
you think otherwise?
|
@mwanji In no other configuration library have I ever seen this functionality. The name is not the quotes, the name is what's in the quotes. |
I agree, the quotes are not meant to be part of the quoted keys, they are just a syntactic delimiter. This can be seen in the spec: https://github.com/toml-lang/toml#keyvalue-pair where it says: "Quoted keys follow the exact same rules as either basic strings or literal strings and allow you to use a much broader set of key names". This means the quotes are not part of the key name, just as they are not part of the string value. This also apples to table key names, and again can be seen from this example in the spec ( https://github.com/toml-lang/toml#table ) : Naming rules for each dot separated part are the same as for keys (see definition of Key/Value Pairs). [dog."tater.man"]
type = "pug" In JSON land, that would give you the following structure: { "dog": { "tater.man": { "type": "pug" } } } If quotes were part of the key name, then the equivalent JSON for the TOML above would instead be: { "dog": { "\"tater.man\"": { "type": "pug" } } } but it's not. |
OK, I'm convinced and will change this behaviour soon. |
I have an issue that you might be able to help me solve. Quoted keys allow the use of dots and square brackets. This conflicts with the deep navigation feature, eg. Currently, this expects a table called tater containing another table called man. I guess I could use some heuristics to discover that there is a table called tater.man, but this seems messy, error-prone and confusing. The use of square brackets (outside of quotes) indicates array navigation, but now any random use of square brackets would have to be understood. What if someone calls a table "dog[2]", then calls |
@mwanji In the Configurate library, which I use frequently, instead of calling As for the random square brackets, I'm curious as to why you've got the current format. I've never seen a configuration library do that. The string is the key, yes? Why is extra information that isn't the key also in the string? I'd personally change that to be a separate method. Or just don't include it - people could easily do an inline call to Edit: Alternatively, to avoid breaking existing code, you could do another method overload here: |
Yeah, I essentially agree with @pie-flavor. You'll need an API like You're going to have some issues with backwards compatibility too... |
Thanks for the feedback, @pie-flavor and @bruno-medeiros . I'll change the existing method to a varargs. I'm not really worrying about backwards compatibility until TOML goes 1.0, which is when this library will, too. However, someone using the deep navigation feature will start getting erroneous results after upgrading. Is there anything I could do beyond documentation? Print out a warning if a key with a dot in it doesn't point to anything? |
Usually my solution to this is to ignore it - it's on them for not reading the updated documentation. If only there was a way to put a message in the |
Definitely you shouldn't print a warning: some programs need absolute control of what goes into stdout and stderr, and toml4j shouldn't interefere with that. |
@mwanji Once it has a varargs in it, all existing calls to the method will break, since the signature has changed. They can look up why their code is breaking, and notice the difference then. But I agree with @bruno-medeiros. |
Any sort of status on this? |
@pie-flavor Sorry this is taking so long. I have done some work on it, but repeatedly ran into issues. Latest was that the varargs approach conflicted with the existing way to provide a default value, ie. With Java 8's Optional, I can eliminate the default value overload, and use it for navigation instead. The API looks like this: Plus, Java 8 will provide much better support for the more sophisticated date/time system that has been added to TOML. I'll publish this work in a branch as soon as I can, and let you know. |
Status update? |
happy belated third birthday to this super basic issue |
wow, pie flavor in the wild anyways yeah im switching to a different toml library this is ridiculous |
I have beef with the policy on quoted key loading. It doesn't make sense to require that the query have the same quotes. The point of quoted keys are that the quotes only exist in the file, theyr'e not part of the key name. There should be at least a boolean parameter whether or not to load it this way.
The text was updated successfully, but these errors were encountered: