-
Notifications
You must be signed in to change notification settings - Fork 2
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
Save config to file #5
Comments
Hi @Nicklas2751, first things first, thanks a lot for your feedback. I'll try to elaborate a little bit more your use case just to make sure that my understanding is correct (or wrong). From your comment, it seems that you are reading some YAML configuration and, I guess, you are mapping that configuration to some Java POJO. What you would like to do (and I'm really speculating here) is to change some property of the POJO (maybe through some setter) and then have the same changes reflected in the original YAML file used as source. Is that your use case? |
Yes it is. |
My personal feeling (and I may be wrong here) is that this feature is a bit outside the scope of a configuration library, as far as the common interpretation of "configuration library" goes. I've just double checked other configuration libraries (to make sure I didn't miss anything obvious like this) and, unfortunately, none of them seem to cover this particular use case either. Now, getting back to your scenario, would it be too bad to handle the write part using something like Jackson? You would need to just create a YAML-specific ObjectMapper (something similar to what I do here) and use the writeValue method. |
I tried it with using your ObjectMapper and writing with Jackson back to YAML but the YAML it generated had other information las the original. In the original i have something like this:
which Type is a
|
The reasons why you are getting that is due to how Jackson serialization/deserialization works and the fact that When deserializing (i.e. reading the configuration through yacl4j), Jackson automatically detects that there is a static When serializing (i.e. writing the configuration with your custom code), Jackson inspects the Level class and finds that there are two getters ( If you keep using Jackson, I guess you have (at least) two options:
I hope that helped. |
I found this project when i was searching for a library to handle YAML configurations for mediathekview/MServer. The configuration reading works really fine and I'm very glad with it. But I'm very sad about the fact, there is no option to save a changed configuration back to a YAML file.
Please add support for writing the configuration back to YAML.
The text was updated successfully, but these errors were encountered: