Skip to content

Commit

Permalink
Use JSON.generate instead of to_json
Browse files Browse the repository at this point in the history
  • Loading branch information
lwrubel committed Dec 5, 2023
1 parent b6b8ef2 commit 6eb5412
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 161 deletions.
2 changes: 1 addition & 1 deletion app/views/purl/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<%= tag :meta, name: 'citation_doi', content: @purl.doi_id %>
<% end %>
<% if @purl.schema_dot_org? %>
<script type="application/ld+json"><%= @purl.schema_dot_org.to_json.html_safe %></script>
<script type="application/ld+json"><%= @purl.schema_dot_org.html_safe %></script>
<% end %>
<% end %>

Expand Down
14 changes: 7 additions & 7 deletions lib/metadata/schema_dot_org.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ def initialize(cocina_json)
end

def call
{
"@context": 'http://schema.org',
"@type": schema_type,
"name": title_name,
"description": description
}.merge(format_specific_fields)
.compact
schema_fields = { "@context": 'http://schema.org',
"@type": schema_type,
"name": title_name,
"description": description }
.merge(format_specific_fields)
.compact
JSON.generate(schema_fields)
end

def schema_type?
Expand Down
Loading

0 comments on commit 6eb5412

Please sign in to comment.