带有@符号的JBuilder json密钥使用json-ld来使用schema.org元数据

时间:2015-01-02 05:18:08

标签: json ruby-on-rails-4 schema.org jbuilder json-ld

在我的jbuilder模板中,我无法使用" @"符号。例如"上下文@&#34 ;.我该怎么办。

我的应用程序中需要json-ld元数据这样的键。

我希望得到json,如下所示

<script type="application/ld+json">

{
    "@context": "http://schema.org",
    "@type": "Article",
    "publisher": "The Ghost Blog",
    "author": {
        "@type": "Person",
        "name": "John O'Nolan",
        "image": "http://blog.ghost.org/content/images/2013/Nov/gravatar_j7_200.jpg",
        "url": "http://blog.ghost.org/author/john",
        "sameAs": "http://twitter.com/JohnONolan"
    },
    "headline": "11 Tools We Use at Ghost for Distributed Teams &amp; Digital Nomads",
    "url": "http://blog.ghost.org/distributed-team-tools/",
    "datePublished": "2014-12-15T14:09:18.000Z",
    "dateModified": "2014-12-18T22:13:49.000Z",
    "image": "http://blog.ghost.org/content/images/2014/12/ghostdistrib.jpg",
    "keywords": "Remote Work",
    "description": "Doing remote work is tough. The freedom is great, but distributed team tools and communication are essential to making it work. Here are our top apps...."
}
    </script>

1 个答案:

答案 0 :(得分:6)

解决了它。这很简单。

json.set! "@context", "http://schema.org"