module JSON

def [](object, opts = nil)

JSON[ruby] # => '[0,1,null]'
ruby = [0, 1, nil]
Otherwise, calls JSON.generate with +object+ and +opts+ (see method #generate):

JSON[json]# => [0, 1, nil]
json = '[0, 1, null]'
calls JSON.parse with +object+ and +opts+ (see method #parse):
If +object+ is a \String,

JSON[object] -> new_array or new_string
:call-seq:
def [](object, opts = nil)
  if object.is_a?(String)
    return JSON.parse(object, opts)
  elsif object.respond_to?(:to_str)
    str = object.to_str
    if str.is_a?(String)
      return JSON.parse(str, opts)
    end
  end
  JSON.generate(object, opts)
end