-
Notifications
You must be signed in to change notification settings - Fork 158
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
avoid type loss with JSON unmarshal/marshal #64
Conversation
This is cool. Just need to figure out why the tests are failing: https://travis-ci.com/github/knadh/koanf/jobs/484967206 |
Ints should avoid calling Ints64s to avoid unneeded conversion between []in64 and []int. MergeAt unit test cannot be tested against JSON file since JSON treats numbers as float64 and confmap.Provider/YAML treats them as integers.
See my latest commit, it seems that there were some issues.
|
Does that mean |
With the current behavior, the latest loaded file will override the current type so I don't think it will be a problem. Having said that:
This makes the behavior of getters somewhat inconsistent if someone loads multiple files and will try to get the value of an array. With []int we can promote it to []float64 without loss, but doing []float64 to []int can cause a loss in case there is an actual float array WDYT? |
|
It's possible to check if a |
Yep, checking for whole numbers will work. |
I correct myself this is not an issue
Because I think I will add another test of loading JSON and YAML and see that nothing is broken and you can merge it. |
JSON treats int array as float64 array, this tests checks that there is no issue between type conversions in Load Merge.
Looks good. @rhnvrm could you also please review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, one minor doc change.
issue #63