strip null values from JSON-LD hash

This commit is contained in:
Ben Balter 2017-11-16 11:40:42 -05:00
parent ca1200b90f
commit da96f4d707
No known key found for this signature in database
GPG Key ID: DBB67C246AD356C4
3 changed files with 6 additions and 2 deletions

View File

@ -73,6 +73,10 @@ module Jekyll
alias_method :mainEntityOfPage, :main_entity
private :main_entity
def to_json
to_h.reject { |_k, v| v.nil? }.to_json
end
private
attr_reader :page_drop

View File

@ -157,7 +157,7 @@ RSpec.describe Jekyll::SeoTag::JSONLDDrop do
let(:metadata) { {} }
it "does not return null values as json" do
expect(subject.to_json).to_not match(/:null/)
expect(subject.to_json).to_not match(%r!:null!)
end
end
end

View File

@ -340,7 +340,7 @@ EOS
end
it "removes null values from JSON-LD" do
expect(output).to_not match(/:null/)
expect(output).to_not match(%r!:null!)
end
end
end