Module: ActiveSupport::JSON

Defined in:
activesupport/lib/active_support/json/decoding.rb,
activesupport/lib/active_support/json/variable.rb,
activesupport/lib/active_support/json/encoding.rb

Defined Under Namespace

Modules: Encoding Classes: Variable

Constant Summary

DATE_REGEX =

matches YAML-formatted dates

/^(?:\d{4}-\d{2}-\d{2}|\d{4}-\d{1,2}-\d{1,2}[T \t]+\d{1,2}:\d{2}:\d{2}(\.[0-9]*)?(([ \t]*)Z|[-+]\d{2}?(:\d{2})?))$/
CircularReferenceError =
Deprecation::DeprecatedConstantProxy.new('ActiveSupport::JSON::CircularReferenceError', Encoding::CircularReferenceError)

Class Method Summary (collapse)

Class Method Details

+ (Object) decode(json, options = {})



11
12
13
14
15
16
17
18
# File 'activesupport/lib/active_support/json/decoding.rb', line 11

def decode(json, options ={})
  data = MultiJson.decode(json, options)
  if ActiveSupport.parse_json_times
    convert_dates_from(data)
  else
    data
  end
end

+ (Object) encode(value, options = nil)

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



30
31
32
# File 'activesupport/lib/active_support/json/encoding.rb', line 30

def self.encode(value, options = nil)
  Encoding::Encoder.new(options).encode(value)
end

+ (Object) engine Also known as: backend



20
21
22
# File 'activesupport/lib/active_support/json/decoding.rb', line 20

def engine
  MultiJson.engine
end

+ (Object) engine=(name) Also known as: backend=



25
26
27
# File 'activesupport/lib/active_support/json/decoding.rb', line 25

def engine=(name)
  MultiJson.engine = name
end

+ (Object) parse_error



37
38
39
# File 'activesupport/lib/active_support/json/decoding.rb', line 37

def parse_error
  MultiJson::DecodeError
end

+ (Object) with_backend(name)



30
31
32
33
34
35
# File 'activesupport/lib/active_support/json/decoding.rb', line 30

def with_backend(name)
  old_backend, self.backend = backend, name
  yield
ensure
  self.backend = old_backend
end