class Sinatra::Base

def nested_params(params)

def nested_params(params)
  return indifferent_hash.merge(params) if !params.keys.join.include?('[')
  params.inject indifferent_hash do |res, (key,val)|
    if key =~ /\[.*\]/
      splat = key.scan(/(^[^\[]+)|\[([^\]]+)\]/).flatten.compact
      head, last = splat[0..-2], splat[-1]
      head.inject(res){ |s,v| s[v] ||= indifferent_hash }[last] = val
    end
    res
  end
end