Merge pull request #67 from Iazel/patch-1

Quotes string starting with a dot
This commit is contained in:
David Tolnay 2017-05-08 11:16:27 -07:00 committed by GitHub
commit 312b370f4e

View file

@ -291,6 +291,7 @@ fn need_quotes(string: &str) -> bool {
|| string == "false" || string == "false"
|| string == "null" || string == "null"
|| string == "~" || string == "~"
|| string.starts_with('.')
|| string.parse::<i64>().is_ok() || string.parse::<i64>().is_ok()
|| string.parse::<f64>().is_ok() || string.parse::<f64>().is_ok()
} }
@ -394,6 +395,8 @@ products:
amount: 4 amount: 4
"*cookies": "*cookies":
amount: 4 amount: 4
".milk":
amount: 1
"2.4": real key "2.4": real key
"[1,2,3,4]": array key "[1,2,3,4]": array key
"true": bool key "true": bool key