解析 YAML 文件后,我需要在 Ruby 数组中具有正确的值顺序。
我有这个简单的例子来显示我的问题:
x = "columns:\n col_1 : ~\n col_2 : ~\n col_3 : ~\n col4 : ~"
s = YAML::load(x)
控制台输出给出:
x = "列:\n col_1:~\n col_2:~\n col_3:~\n col4:~"
=> "列:\n col_1:~\n col_2:~\n col_3:~\n col4: ~"
s = YAML::load(x)
=> {"columns"=>{"col_3"=>nil, "col4"=>nil, "col_1"=>nil, "col_2"=>nil}}
“列”数组的顺序与输入数据中的顺序不同:(