class Chef::Resource::File::Verification::Json

Extends File verification to provide Json verification

Example: file ‘foo.json’ do

content '{"foo": "bar"}'
verify :json

end

Public Instance Methods

verify(path, opts = {}) click to toggle source
# File lib/chef/resource/file/verification/json.rb, line 39
def verify(path, opts = {})
  Chef::JSONCompat.parse(TargetIO::IO.read(path))
  true
rescue Chef::Exceptions::JSON::ParseError => e
  Chef::Log.error("Json syntax verify failed with : #{e.message}")
  false
end