There is a pearl of JSON-LD ( http://rubygems.org/gems/json-ld ), but this may not be exactly what you are looking for. Note that the JSON-LD point is that it is just JSON, in which case the schema.org context is used to interpret the values. Assuming your data is in ActiveRecord models, you'll need a way to make sure the record properties match the corresponding schema.org properties. If so, then just serializing your model for JSON (#to_json) will get you most of the way. It remains to add the fields @context , @id and @type in JSON.
For example, let's say you have a User model that is serialized like this:
{ "name": "Harry", "email": " Harry@example.org " }
As the properties "name" and "email address" of http://schema.org/Person , you can get the part there by simply adding @context and @type as follows
{ "@context": "http://schema.org/", "@type": "Person", "name": "Harry", "email": " Harry@example.org " }
Assuming you are creating a RESTful application, it is good practice to provide each @id object that matches the resource URL for that person. This may be as follows:
{ "@context": "http://schema.org/", "@id": "http://example.com/people/harry", "@type": "Person", "name": "Harry", "email": " Harry@example.org " }
Now, if you get http://example.com/people/harry as JSON (or JSON-LD), you can return this view.
Another thing about JSON-LD is that it is for “Related Data”, so including links to other resources is useful so that you can find them, as you probably do in your HTML. The schema.org documentation includes numerous examples of how to create various types of markup, including JSON-LD, for most of the types that they define. See http://schema.org/Person for one example or http://schema.org/docs/full.html for their complete type hierarchy.
The JSON-LD driver comes in handy when you want to generate this data from other sources (usually in RDF format) or interpret the received data. You can experiment with this at http://json-ld.org/playground .
You can also include JSON-LD in HTML using a script tag with type = "application / ld + json", as your example does. If you want to see how your data looks, you can check it either in the Google Structured Data Testing Tool or at http://linter.structured-data.org/