How to pass ruby variable to logstash field?

The below is my sample code, where i'm passing input response to the filter. Here XYZ is a field name from the input.

ruby{
"init => '@var'
code => "
event.set('var',event.get('XYZ'))
require 'open-uri'
response = open('http://xyz.com?q="@var"').read
puts response
}

Here response will get some JSON data, now i should apply json filter on response.

like json {
           source => "response"
}

but it is not working.