This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> YAML.load "test: 09333" | |
=> {"test"=>"09333"} # Perfect | |
> YAML.load "test: 04135" | |
=> 2141 # WTF?! |
So, it turns out that it assumes numbers with a leading zero to be an octal, and tries to be helpful by converting them for us. More trial and error lead us to find that single quotes help, but require a little c in some cases. Here are the results of trying various things. Notice the different placement of single quotes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> YAML.load("test: 09333\n") | |
=> {"test"=>"09333"} | |
> YAML.load("test: '09333\n'") | |
=> {"test"=>"09333 "} | |
> YAML.load('test: 09333\n') | |
=> {"test"=>"09333\\n"} | |
> YAML.load("test: '09333'\n") | |
=> {"test"=>"09333"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> YAML.load("test: 04135\n") | |
=> {"test"=>2141} | |
> YAML.load("test: '04135\n'") | |
=> {"test"=>"04135 "} | |
> YAML.load('test: 04135\n') | |
=> {"test"=>"04135\\n"} | |
> YAML.load("test: '04135'\n") | |
=> {"test"=>"04135"} |
I hope this helps someone out. If so, let me know!