aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/json/encoders
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/json/encoders')
-rw-r--r--activesupport/lib/active_support/json/encoders/date.rb22
-rw-r--r--activesupport/lib/active_support/json/encoders/date_time.rb22
-rw-r--r--activesupport/lib/active_support/json/encoders/enumerable.rb13
-rw-r--r--activesupport/lib/active_support/json/encoders/false_class.rb6
-rw-r--r--activesupport/lib/active_support/json/encoders/hash.rb51
-rw-r--r--activesupport/lib/active_support/json/encoders/nil_class.rb6
-rw-r--r--activesupport/lib/active_support/json/encoders/numeric.rb6
-rw-r--r--activesupport/lib/active_support/json/encoders/object.rb13
-rw-r--r--activesupport/lib/active_support/json/encoders/regexp.rb6
-rw-r--r--activesupport/lib/active_support/json/encoders/string.rb6
-rw-r--r--activesupport/lib/active_support/json/encoders/symbol.rb6
-rw-r--r--activesupport/lib/active_support/json/encoders/time.rb24
-rw-r--r--activesupport/lib/active_support/json/encoders/true_class.rb6
13 files changed, 0 insertions, 187 deletions
diff --git a/activesupport/lib/active_support/json/encoders/date.rb b/activesupport/lib/active_support/json/encoders/date.rb
deleted file mode 100644
index 9adb3c20e2..0000000000
--- a/activesupport/lib/active_support/json/encoders/date.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-class Date
- private
- # Returns a JSON string representing the date. If ActiveSupport.use_standard_json_time_format is set to true, the
- # ISO 8601 format is used.
- #
- # ==== Examples
- #
- # # With ActiveSupport.use_standard_json_time_format = true
- # Date.new(2005,2,1).to_json
- # # => "2005-02-01"
- #
- # # With ActiveSupport.use_standard_json_time_format = false
- # Date.new(2005,2,1).to_json
- # # => "2005/02/01"
- def rails_to_json(*)
- if ActiveSupport.use_standard_json_time_format
- %("#{strftime("%Y-%m-%d")}")
- else
- %("#{strftime("%Y/%m/%d")}")
- end
- end
-end
diff --git a/activesupport/lib/active_support/json/encoders/date_time.rb b/activesupport/lib/active_support/json/encoders/date_time.rb
deleted file mode 100644
index 3a29292b24..0000000000
--- a/activesupport/lib/active_support/json/encoders/date_time.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-class DateTime
- private
- # Returns a JSON string representing the datetime. If ActiveSupport.use_standard_json_time_format is set to true, the
- # ISO 8601 format is used.
- #
- # ==== Examples
- #
- # # With ActiveSupport.use_standard_json_time_format = true
- # DateTime.civil(2005,2,1,15,15,10).to_json
- # # => "2005-02-01T15:15:10+00:00"
- #
- # # With ActiveSupport.use_standard_json_time_format = false
- # DateTime.civil(2005,2,1,15,15,10).to_json
- # # => "2005/02/01 15:15:10 +0000"
- def rails_to_json(*)
- if ActiveSupport.use_standard_json_time_format
- xmlschema.inspect
- else
- strftime('"%Y/%m/%d %H:%M:%S %z"')
- end
- end
-end
diff --git a/activesupport/lib/active_support/json/encoders/enumerable.rb b/activesupport/lib/active_support/json/encoders/enumerable.rb
deleted file mode 100644
index 898990a59c..0000000000
--- a/activesupport/lib/active_support/json/encoders/enumerable.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-module Enumerable
- private
- # Returns a JSON string representing the enumerable. Any +options+
- # given will be passed on to its elements. For example:
- #
- # users = User.find(:all)
- # # => users.to_json(:only => :name)
- #
- # will pass the <tt>:only => :name</tt> option to each user.
- def rails_to_json(options = nil, *args) #:nodoc:
- "[#{map { |value| ActiveSupport::JSON.encode(value, options, *args) } * ','}]"
- end
-end
diff --git a/activesupport/lib/active_support/json/encoders/false_class.rb b/activesupport/lib/active_support/json/encoders/false_class.rb
deleted file mode 100644
index eb975fe542..0000000000
--- a/activesupport/lib/active_support/json/encoders/false_class.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class FalseClass
- private
- def rails_to_json(*)
- 'false'
- end
-end
diff --git a/activesupport/lib/active_support/json/encoders/hash.rb b/activesupport/lib/active_support/json/encoders/hash.rb
deleted file mode 100644
index 4771484843..0000000000
--- a/activesupport/lib/active_support/json/encoders/hash.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-require 'active_support/core_ext/array/wrap'
-
-class Hash
- private
- # Returns a JSON string representing the hash.
- #
- # Without any +options+, the returned JSON string will include all
- # the hash keys. For example:
- #
- # { :name => "Konata Izumi", 'age' => 16, 1 => 2 }.to_json
- # # => {"name": "Konata Izumi", "1": 2, "age": 16}
- #
- # The keys in the JSON string are unordered due to the nature of hashes.
- #
- # The <tt>:only</tt> and <tt>:except</tt> options can be used to limit the
- # attributes included, and will accept 1 or more hash keys to include/exclude.
- #
- # { :name => "Konata Izumi", 'age' => 16, 1 => 2 }.to_json(:only => [:name, 'age'])
- # # => {"name": "Konata Izumi", "age": 16}
- #
- # { :name => "Konata Izumi", 'age' => 16, 1 => 2 }.to_json(:except => 1)
- # # => {"name": "Konata Izumi", "age": 16}
- #
- # The +options+ also filter down to any hash values. This is particularly
- # useful for converting hashes containing ActiveRecord objects or any object
- # that responds to options in their <tt>to_json</tt> method. For example:
- #
- # users = User.find(:all)
- # { :users => users, :count => users.size }.to_json(:include => :posts)
- #
- # would pass the <tt>:include => :posts</tt> option to <tt>users</tt>,
- # allowing the posts association in the User model to be converted to JSON
- # as well.
- def rails_to_json(options = nil, *args) #:nodoc:
- hash_keys = self.keys
-
- if options
- if except = options[:except]
- hash_keys = hash_keys - Array.wrap(except)
- elsif only = options[:only]
- hash_keys = hash_keys & Array.wrap(only)
- end
- end
-
- result = '{'
- result << hash_keys.map do |key|
- "#{ActiveSupport::JSON.encode(key.to_s)}:#{ActiveSupport::JSON.encode(self[key], options, *args)}"
- end * ','
- result << '}'
- end
-end
diff --git a/activesupport/lib/active_support/json/encoders/nil_class.rb b/activesupport/lib/active_support/json/encoders/nil_class.rb
deleted file mode 100644
index 8c51dba384..0000000000
--- a/activesupport/lib/active_support/json/encoders/nil_class.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class NilClass
- private
- def rails_to_json(*)
- 'null'
- end
-end
diff --git a/activesupport/lib/active_support/json/encoders/numeric.rb b/activesupport/lib/active_support/json/encoders/numeric.rb
deleted file mode 100644
index c7cd0df1d7..0000000000
--- a/activesupport/lib/active_support/json/encoders/numeric.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class Numeric
- private
- def rails_to_json(*)
- to_s
- end
-end
diff --git a/activesupport/lib/active_support/json/encoders/object.rb b/activesupport/lib/active_support/json/encoders/object.rb
deleted file mode 100644
index 9cc12d91ac..0000000000
--- a/activesupport/lib/active_support/json/encoders/object.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-require 'active_support/core_ext/object/instance_variables'
-
-class Object
- # Dumps object in JSON (JavaScript Object Notation). See www.json.org for more info.
- def to_json(options = nil)
- ActiveSupport::JSON.encode(self, options)
- end
-
- private
- def rails_to_json(*args)
- ActiveSupport::JSON.encode(instance_values, *args)
- end
-end
diff --git a/activesupport/lib/active_support/json/encoders/regexp.rb b/activesupport/lib/active_support/json/encoders/regexp.rb
deleted file mode 100644
index ee42db4d02..0000000000
--- a/activesupport/lib/active_support/json/encoders/regexp.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class Regexp
- private
- def rails_to_json(*)
- inspect
- end
-end
diff --git a/activesupport/lib/active_support/json/encoders/string.rb b/activesupport/lib/active_support/json/encoders/string.rb
deleted file mode 100644
index 4a6b21c1c0..0000000000
--- a/activesupport/lib/active_support/json/encoders/string.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class String
- private
- def rails_to_json(*)
- ActiveSupport::JSON::Encoding.escape(self)
- end
-end
diff --git a/activesupport/lib/active_support/json/encoders/symbol.rb b/activesupport/lib/active_support/json/encoders/symbol.rb
deleted file mode 100644
index d575350a4e..0000000000
--- a/activesupport/lib/active_support/json/encoders/symbol.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class Symbol
- private
- def rails_to_json(*args)
- ActiveSupport::JSON.encode(to_s, *args)
- end
-end
diff --git a/activesupport/lib/active_support/json/encoders/time.rb b/activesupport/lib/active_support/json/encoders/time.rb
deleted file mode 100644
index d434b9aace..0000000000
--- a/activesupport/lib/active_support/json/encoders/time.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-require 'active_support/core_ext/time/conversions'
-
-class Time
- private
- # Returns a JSON string representing the time. If ActiveSupport.use_standard_json_time_format is set to true, the
- # ISO 8601 format is used.
- #
- # ==== Examples
- #
- # # With ActiveSupport.use_standard_json_time_format = true
- # Time.utc(2005,2,1,15,15,10).to_json
- # # => "2005-02-01T15:15:10Z"
- #
- # # With ActiveSupport.use_standard_json_time_format = false
- # Time.utc(2005,2,1,15,15,10).to_json
- # # => "2005/02/01 15:15:10 +0000"
- def rails_to_json(*)
- if ActiveSupport.use_standard_json_time_format
- xmlschema.inspect
- else
- %("#{strftime("%Y/%m/%d %H:%M:%S")} #{formatted_offset(false)}")
- end
- end
-end
diff --git a/activesupport/lib/active_support/json/encoders/true_class.rb b/activesupport/lib/active_support/json/encoders/true_class.rb
deleted file mode 100644
index bc25a6db78..0000000000
--- a/activesupport/lib/active_support/json/encoders/true_class.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class TrueClass
- private
- def rails_to_json(*)
- 'true'
- end
-end