{"action":"created","issue":{"url":"https://api.github.com/repos/spf13/viper/issues/125","repository_url":"https://api.github.com/repos/spf13/viper","labels_url":"https://api.github.com/repos/spf13/viper/issues/125/labels{/name}","comments_url":"https://api.github.com/repos/spf13/viper/issues/125/comments","events_url":"https://api.github.com/repos/spf13/viper/issues/125/events","html_url":"https://github.com/spf13/viper/issues/125","id":114137060,"number":125,"title":"Snake-Case JSON Fields Ignored by UnmarshalKey()","user":{"login":"coreywkruger","id":4206103,"avatar_url":"https://avatars.githubusercontent.com/u/4206103?v=3","gravatar_id":"","url":"https://api.github.com/users/coreywkruger","html_url":"https://github.com/coreywkruger","followers_url":"https://api.github.com/users/coreywkruger/followers","following_url":"https://api.github.com/users/coreywkruger/following{/other_user}","gists_url":"https://api.github.com/users/coreywkruger/gists{/gist_id}","starred_url":"https://api.github.com/users/coreywkruger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreywkruger/subscriptions","organizations_url":"https://api.github.com/users/coreywkruger/orgs","repos_url":"https://api.github.com/users/coreywkruger/repos","events_url":"https://api.github.com/users/coreywkruger/events{/privacy}","received_events_url":"https://api.github.com/users/coreywkruger/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-29T20:18:38Z","updated_at":"2016-04-29T19:09:21Z","closed_at":null,"body":"I have encountered a situation where snake case fields returned from `UnmarshalKey()` are ignored while non snake case fields are returned normally. The snake case fields are returned as empty strings (the default) as if no value was found. NOTE: Json notation has been included on the struct as per usual. \r\n\r\nFor an example of what I mean, execute the test program in this repo: https://github.com/coreywkruger/viper-test . Instructions are in README.md \r\n\r\nThe json file that is being loaded is of the format:\r\n```json\r\n{\r\n  \"data\":{\r\n\t  \"normal\": \"Normal stuff\",\r\n      \"snake_case\": \"Snake case stuff that is skipped :(\"\r\n\t}\r\n}\r\n```\r\n\r\nThe struct being populated is defined here:\r\n```go\r\ntype configJSON struct {\r\n\tNormal    string `json:\"normal\"`\r\n\tSnakeCase string `json:\"snake_case\"`\r\n}\r\n```\r\n\r\nThe json file is loaded like so:\r\n```go\r\n// Unmarshalling from viper config:\r\nconfig := viper.New()\r\nconfig.SetConfigFile(\"./config.json\")\r\nerr := config.ReadInConfig()\r\nif err != nil {\r\n\tlog.Fatal(err)\r\n}\r\n```\r\n... then un-marshaled  and printed ...\r\n```go\r\nc := configJSON{}\r\nconfig.UnmarshalKey(\"data\", &c)\r\n\r\n// Print out the values of the fields\r\nfmt.Printf(\"normal: `%s`\\n\", c.Normal)\r\nfmt.Printf(\"snake_case: `%s`\\n\", c.SnakeCase) // <-- Notice how this is empty\r\n```\r\nThe console output looks like:\r\n```\r\nnormal: `Normal stuff`\r\nsnake_case: ``\r\n```\r\n`snake_case` is an empty string (but shouldn't be)."},"comment":{"url":"https://api.github.com/repos/spf13/viper/issues/comments/215851237","html_url":"https://github.com/spf13/viper/issues/125#issuecomment-215851237","issue_url":"https://api.github.com/repos/spf13/viper/issues/125","id":215851237,"user":{"login":"trenton42","id":1412655,"avatar_url":"https://avatars.githubusercontent.com/u/1412655?v=3","gravatar_id":"","url":"https://api.github.com/users/trenton42","html_url":"https://github.com/trenton42","followers_url":"https://api.github.com/users/trenton42/followers","following_url":"https://api.github.com/users/trenton42/following{/other_user}","gists_url":"https://api.github.com/users/trenton42/gists{/gist_id}","starred_url":"https://api.github.com/users/trenton42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trenton42/subscriptions","organizations_url":"https://api.github.com/users/trenton42/orgs","repos_url":"https://api.github.com/users/trenton42/repos","events_url":"https://api.github.com/users/trenton42/events{/privacy}","received_events_url":"https://api.github.com/users/trenton42/received_events","type":"User","site_admin":false},"created_at":"2016-04-29T19:09:21Z","updated_at":"2016-04-29T19:09:21Z","body":"I just ran into this, but mainly because I wasn't paying attention. @spf13 I think you can close this as it is [somewhat documented](https://github.com/spf13/viper#unmarshaling) in the readme (but perhaps you can call more attention to it there)."}}