开发者

Ruby YAML delimiter

开发者 https://www.devze.com 2023-01-27 07:17 出处:网络
Is there any way to change the delimiter that is used when Ruby creates a YAML file? What is given right now:

Is there any way to change the delimiter that is used when Ruby creates a YAML file?

What is given right now:

--- 
- de
- abbrv开发者_JS百科_apr: APR

What is wanted:

\t de
\t abbrv_apr: APR

The \t is a tab, so basically I want all of the dashes to be gone from the created yaml files

I was able to fix my problem by creating a nested sequence http://www.yaml.org/YAML_for_ruby.html#nested_sequences


YAML is a format that does not allow for such customizations.

Of course, you can always do obj.to_yaml.gsub(/^-/, "\t") if you need to. (with /^\t/, '-' on read)

0

精彩评论

暂无评论...
验证码 换一张
取 消