Methods
Constants
DECODERS | = | %w(Yajl Yaml) |
Listed in order of preference. |
||
DATE_REGEX | = | /^(?:\d{4}-\d{2}-\d{2}|\d{4}-\d{1,2}-\d{1,2}[ \t]+\d{1,2}:\d{2}:\d{2}(\.[0-9]*)?(([ \t]*)Z|[-+]\d{2}?(:\d{2})?))$/ |
matches YAML-formatted dates |
||
CircularReferenceError | = | Deprecation::DeprecatedConstantProxy.new('ActiveSupport::JSON::CircularReferenceError', Encoding::CircularReferenceError) |
Attributes
[R] | parse_error |
Public Class methods
[ show source ]
# File activesupport/lib/active_support/json/decoding.rb, line 16 16: def backend 17: set_default_backend unless defined?(@backend) 18: @backend 19: end
[ show source ]
# File activesupport/lib/active_support/json/decoding.rb, line 21 21: def backend=(name) 22: if name.is_a?(Module) 23: @backend = name 24: else 25: require "active_support/json/backends/#{name.to_s.downcase}" 26: @backend = ActiveSupport::JSON::Backends::const_get(name) 27: end 28: @parse_error = @backend::ParseError 29: end
Dumps object in JSON (JavaScript Object Notation). See www.json.org for more info.
[ show source ]
# File activesupport/lib/active_support/json/encoding.rb, line 29 29: def self.encode(value, options = nil) 30: Encoding::Encoder.new(options).encode(value) 31: end
[ show source ]
# File activesupport/lib/active_support/json/decoding.rb, line 38 38: def set_default_backend 39: DECODERS.find do |name| 40: begin 41: self.backend = name 42: true 43: rescue LoadError 44: # Try next decoder. 45: false 46: end 47: end 48: end
[ show source ]
# File activesupport/lib/active_support/json/decoding.rb, line 31 31: def with_backend(name) 32: old_backend, self.backend = backend, name 33: yield 34: ensure 35: self.backend = old_backend 36: end