{"id":89,"date":"2015-03-30T04:06:38","date_gmt":"2015-03-30T04:06:38","guid":{"rendered":"http:\/\/svops.com\/blog\/?p=89"},"modified":"2015-03-31T22:28:03","modified_gmt":"2015-03-31T22:28:03","slug":"casting-variables-in-the-ruby-filter","status":"publish","type":"post","link":"http:\/\/svops.com\/blog\/casting-variables-in-the-ruby-filter\/","title":{"rendered":"Casting variables in the ruby{} filter"},"content":{"rendered":"<p>Note that the mutate{} filter contains a convert{} operation, which is very useful.<\/p>\n<p>If you find yourself in ruby for another purpose, you might want to cast the variables while your there. \u00a0Here are some examples:<\/p>\n<pre>      ruby {\r\n        code =&gt; \"\r\n          begin\r\n            event['foo'] = event['foo'].to_f\r\n            event['bar'] = event['bar'].to_i\r\n          rescue Exception;\r\n            event['ruby_exception'] = 'cast'\r\n          end\r\n        \"\r\n      }<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Note that the mutate{} filter contains a convert{} operation, which is very useful. If you find yourself in ruby for another purpose, you might want to cast the variables while your there. \u00a0Here are some examples: ruby { code =&gt; &hellip; <a href=\"http:\/\/svops.com\/blog\/casting-variables-in-the-ruby-filter\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[14],"tags":[],"_links":{"self":[{"href":"http:\/\/svops.com\/blog\/wp-json\/wp\/v2\/posts\/89"}],"collection":[{"href":"http:\/\/svops.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/svops.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/svops.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/svops.com\/blog\/wp-json\/wp\/v2\/comments?post=89"}],"version-history":[{"count":3,"href":"http:\/\/svops.com\/blog\/wp-json\/wp\/v2\/posts\/89\/revisions"}],"predecessor-version":[{"id":102,"href":"http:\/\/svops.com\/blog\/wp-json\/wp\/v2\/posts\/89\/revisions\/102"}],"wp:attachment":[{"href":"http:\/\/svops.com\/blog\/wp-json\/wp\/v2\/media?parent=89"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/svops.com\/blog\/wp-json\/wp\/v2\/categories?post=89"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/svops.com\/blog\/wp-json\/wp\/v2\/tags?post=89"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}