I\'m trying to gracefully handle bad JSON for the following, where Hash#fetch
doesn\'t seem to be an option (Handle bad JSON gracefully with Hash#fetch):
I not sure about right syntax in product.price = product.deep_fetch(attribute, { 'not found' })
:
mashie.products.each do |product|
product.extend Hashie::Extensions::DeepFetch
i%[name sale_price currency].each do |attribute|
product.price = product.deep_fetch attribute { 'not found' }
end
@products << product
end