How to covert boolean to integer

try to use

       mutate {
               conver => ["type", 'integer']
            }

but I got error

NoMethodError: undefined method `to_i' for false:FalseClass
  convert_integer at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-filter-mutate-2.0.6/lib/logstash/filters/mutate.rb:296
             call at org/jruby/RubyMethod.java:120
          convert at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-filter-mutate-2.0.6/lib/logstash/filters/mutate.rb:279
             each at org/jruby/RubyHash.java:1342
          convert at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-filter-mutate-2.0.6/lib/logstash/filters/mutate.rb:265
           filter at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-filter-mutate-2.0.6/lib/logstash/filters/mutate.rb:220
     multi_filter at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.4.0-java/lib/logstash/filters/base.rb:151
             each at org/jruby/RubyArray.java:1613
     multi_filter at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.4.0-java/lib/logstash/filters/base.rb:148
      filter_func at (eval):96
     filter_batch at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.4.0-java/lib/logstash/pipeline.rb:267
             each at org/jruby/RubyArray.java:1613
           inject at org/jruby/RubyEnumerable.java:852
     filter_batch at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.4.0-java/lib/logstash/pipeline.rb:265
      worker_loop at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.4.0-java/lib/logstash/pipeline.rb:223
    start_workers at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.4.0-java/lib/logstash/pipeline.rb:201

So I have to convert it To string first ,then to interge

        mutate {
            convert => {"[json][type]"=> "string"}
        }
        if [json][type] == 'true'{
            mutate {
                replace => {"[json][type]"=> 1}
            }
        } else if [json][type]=='false' {
            mutate {
                replace => {"[json][type]"=> 0}
            }
        }
        mutate {
            convert => {"[json][type]"=> "integer"}
        }
1 Like