Answers for "convert ruby hash to json string"

-1

how to json into hash ruby

response = Faraday.get('https://api.github.com/users/your_username')
r = JSON.parse(response.body, symbolize_names: true)
#OR
JSON.parse(response.body)
#'symbolize_names' turns the keys in this hash into symbols, not required
#JSON.parse is what turns the JSON object into a hash
Posted by: Guest on October-06-2020
0

convert ruby hash to json string

WEBHOOK_SECRET = 'webhook secret key';
post '/payload' do
    request.body.rewind
    body = request.body.read
    signature = request.env['HTTP_X_TAWK_SIGNATURE']
    unless verifySignature(body, signature))
        // verification failed
    end
    // verification success
end
def verifySignature(body, signature)
    digest = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), WEBHOOK_SECRET, body)
    return digest == signature
end
Posted by: Guest on October-07-2021

Browse Popular Code Answers by Language