Ruby on rails 如何在html文件中输出json对象?
我正在使用middleman生成HTML,我希望输出一个json ld对象,如下所示:Ruby on rails 如何在html文件中输出json对象?,ruby-on-rails,ruby,erb,Ruby On Rails,Ruby,Erb,我正在使用middleman生成HTML,我希望输出一个json ld对象,如下所示: <script type="application/ld+json"> { "@context": "http://schema.org", "@type": "Person", "name": "John Doe", "jobTitle": "Graduate research assistant", "affiliation": "University of Dreams"
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Person",
"name": "John Doe",
"jobTitle": "Graduate research assistant",
"affiliation": "University of Dreams",
"additionalName": "Johnny",
"url": "http://www.example.com",
"address": {
"@type": "PostalAddress",
"streetAddress": "1234 Peach Drive",
"addressLocality": "Wonderland",
"addressRegion": "Georgia"
}
}
</script>
{
“@context”:”http://schema.org",
“@type”:“Person”,
“姓名”:“约翰·多伊”,
“职位名称”:“研究生研究助理”,
“附属机构”:“梦想大学”,
“附加名称”:“约翰尼”,
“url”:”http://www.example.com",
“地址”:{
“@type”:“PostalAddress”,
“街道地址”:“桃花路1234号”,
“地址地点”:“仙境”,
“地区”:“格鲁吉亚”
}
}
我在一个对象中以正确的方式构造了数据,有没有好的方法输出它 要以正确的格式输出,应该如下所示:
%script{type: 'application/ld+json'}
:plain
{
"@context": "http://schema.org",
"@type": "Person",
"name": "John Doe",
"jobTitle": "Graduate research assistant",
"affiliation": "University of Dreams",
"additionalName": "Johnny",
"url": "http://www.example.com",
"address": {
"@type": "PostalAddress",
"streetAddress": "1234 Peach Drive",
"addressLocality": "Wonderland",
"addressRegion": "Georgia"
}
}
可能重复的