0

I'm using middleman to generate HTML, I wish to output a json-ld-object, something like this:

<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>

I have the data structured in the right way in an object, is there a good way to output it?

Himmators
  • 14,278
  • 36
  • 132
  • 223
  • Possible duplicate of http://stackoverflow.com/questions/4464050/ruby-objects-and-json-serialization-without-rails – Wand Maker Jul 13 '15 at 20:39

1 Answers1

0

To output it in the right format it should be like:

%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"
    }
  }