-
Notifications
You must be signed in to change notification settings - Fork 30
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
Load to object instead of class #45
Comments
Thanks for the suggestion. You should be able to achieve that easily enough using the I would be a little reluctant to implement that directly in the library because I'm not entirely sure what all interfaces users would want the objects to implement (nothing? Everything If there was a consensus from a bunch of users I'd probably be more open to implementing something, but you're the first person to ask for this. (Of course, there's no discussion list for this library, either, so no real way to ask other users for opinions, either ...) As to enabling autocompletion in editors, I'm not actually sure how that would work for generic objects ... If you had a pointer describing what might be needed, I'd be interested in learning more. How does that sound? |
Hey, Regarding autocompletion, I am using a "DefaultConfig" in a python class, which has the same structure/attributes as the previously used munchified Json5 config ().
Thanks for your ideas though :) |
Thanks. How are you solving this problem using python files for configuration? Are you using some library that'll preserve comments, or are you rolling your own logic? [ Preserving comments in pyjson5 is issue #28 ] Implementing everything Using a default object as a parameter type makes sense, but I'm not sure how that'd work when trying to I'll leave this open in case others have similar requests in the future. [ Note to self for future reference: munch (munchify is part of that). ] |
Uhm I am displaying the .py files using the normal open and .readlines() / .writlines() Operator. In order to retrieve the config, I use the builtin runpy.run_path() function to retrieve the class. In my case all config files have the same structure, just different attributes. |
Gotcha. |
Closing as the user found a workaround |
Hey,
within the JSON5 Format one can use ObjectKeys, which are not quoted/strings.
Is it possible to load those json files straight to an object, instead of a dict?
This would make accessing and using the data much more convenient, especially if one has a file with many levels.
It should also enable autocompletion in many Editors (if a dummyObject with the same structure as the file is given).
An example is given below:
The text was updated successfully, but these errors were encountered: