JBuilder json 带有@符号的键使用 json-ld 使用 schema.org 元数据
JBuilder json keys with @ symbol to use schema.org metadata using json-ld
在我的 jbuilder 模板中,我无法使用以“@”符号开头的键。例如“@语境”。我该怎么办
我的应用程序中 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 & 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>
解决了。很简单。
json.set! "@context", "http://schema.org"
在我的 jbuilder 模板中,我无法使用以“@”符号开头的键。例如“@语境”。我该怎么办
我的应用程序中 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 & 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>
解决了。很简单。
json.set! "@context", "http://schema.org"