require 'rack/utils/okjson'

module Lotus
  module Routing
    module Parsing
      class JsonParser < Parser
        def mime_types
          ['application/json']
        end

        def parse(body)
          Rack::Utils::OkJson.decode(body)
        end
      end
    end
  end
end

require 'json'

module Lotus
  module Routing
    module Parsing
      class JsonParser < Parser
        def mime_types
          ['application/json']
        end

        def parse(body)
          JSON.parse(body)
        end
      end
    end
  end
end

Switch to Ruby's native JSON parser
Switch to Ruby's native JSON parser

Ruby's JSON parser is ~20x faster, because it's written in C.

Calculating -------------------------------------
                ruby       204 i/100ms
                rack         6 i/100ms
-------------------------------------------------
                ruby     2071.8 (±5.1%) i/s -      10404 in   5.034635s
                rack       68.6 (±4.4%) i/s -        342 in   5.001516s
