module ActiveSupport::JSON

Constants

DATE_REGEX

matches YAML-formatted dates

Public Class Methods

backend()
Alias for: engine
backend=(name)
Alias for: engine=
decode(json, options ={}) click to toggle source
# File lib/active_support/json/decoding.rb, line 11
def decode(json, options ={})
  # Can't reliably detect whether MultiJson responds to load, since it's
  # a reserved word. Use adapter as a proxy for new features.
  data = if MultiJson.respond_to?(:adapter)
    MultiJson.load(json, options)
  else
    MultiJson.decode(json, options)
  end
  if ActiveSupport.parse_json_times
    convert_dates_from(data)
  else
    data
  end
end
encode(value, options = nil) click to toggle source

Dumps object in JSON (JavaScript Object Notation). See www.json.org for more info.

# File lib/active_support/json/encoding.rb, line 30
def self.encode(value, options = nil)
  Encoding::Encoder.new(options).encode(value)
end
engine() click to toggle source
# File lib/active_support/json/decoding.rb, line 26
def engine
  if MultiJson.respond_to?(:adapter)
    MultiJson.adapter
  else
    MultiJson.engine
  end
end
Also aliased as: backend
engine=(name) click to toggle source
# File lib/active_support/json/decoding.rb, line 35
def engine=(name)
  if MultiJson.respond_to?(:use)
    MultiJson.use name
  else
    MultiJson.engine = name
  end
end
Also aliased as: backend=
parse_error() click to toggle source
# File lib/active_support/json/decoding.rb, line 51
def parse_error
  MultiJson::DecodeError
end
with_backend(name) { || ... } click to toggle source
# File lib/active_support/json/decoding.rb, line 44
def with_backend(name)
  old_backend, self.backend = backend, name
  yield
ensure
  self.backend = old_backend
end