【问题标题】:What does `@` mean in YAML (which causes Psych::SyntaxError)?`@` 在 YAML 中是什么意思(导致 Psych::SyntaxError)?
【发布时间】:2013-11-28 00:18:03
【问题描述】:

@ 是 YAML 中的保留符号吗?当我强迫它成为一个字符串时,一切都很好

require 'yaml'
k = "test: @hello"
YAML.load(k)
# => {"test"=>"@hello"}

但是,如果我不加引号,它会给我Psych::SyntaxError。这是为什么? @<something>在YAML中有什么特殊含义吗?

require 'yaml'
k = "test: @hello"
YAML.load(k)
# => Psych::SyntaxError: (<unknown>): found character that cannot start any token while scanning for the next token ...

【问题讨论】:

    标签: ruby yaml


    【解决方案1】:

    来自 YAML 规范,指示符字符 (link):

    “@”(#x40,at)和“`”(#x60,重音)保留供将来使用。

    【讨论】:

      【解决方案2】:

      是的,它是保留的。见示例 5.10 http://www.yaml.org/spec/1.2/spec.html

      【讨论】:

        猜你喜欢
        • 2022-10-15
        • 1970-01-01
        • 2018-03-20
        • 1970-01-01
        • 2016-02-23
        • 2018-04-24
        • 2015-11-02
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多