summaryrefslogtreecommitdiff
path: root/trunk/ext/json/lib/json/add/rails.rb
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-25 15:13:14 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-25 15:13:14 +0000
commitd0233291bc8a5068e52c69c210e5979e5324b5bc (patch)
tree7d9459449c33792c63eeb7baa071e76352e0baab /trunk/ext/json/lib/json/add/rails.rb
parent0dc342de848a642ecce8db697b8fecd83a63e117 (diff)
parent72eaacaa15256ab95c3b52ea386f88586fb9da40 (diff)
re-adding tag v1_9_0_4 as an alias of trunk@18848v1_9_0_4
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_9_0_4@18849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'trunk/ext/json/lib/json/add/rails.rb')
-rw-r--r--trunk/ext/json/lib/json/add/rails.rb58
1 files changed, 0 insertions, 58 deletions
diff --git a/trunk/ext/json/lib/json/add/rails.rb b/trunk/ext/json/lib/json/add/rails.rb
deleted file mode 100644
index e86ed1aab9..0000000000
--- a/trunk/ext/json/lib/json/add/rails.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-# This file contains implementations of rails custom objects for
-# serialisation/deserialisation.
-
-unless Object.const_defined?(:JSON) and ::JSON.const_defined?(:JSON_LOADED) and
- ::JSON::JSON_LOADED
- require 'json'
-end
-
-class Object
- def self.json_create(object)
- obj = new
- for key, value in object
- next if key == 'json_class'
- instance_variable_set "@#{key}", value
- end
- obj
- end
-
- def to_json(*a)
- result = {
- 'json_class' => self.class.name
- }
- instance_variables.inject(result) do |r, name|
- r[name[1..-1]] = instance_variable_get name
- r
- end
- result.to_json(*a)
- end
-end
-
-class Symbol
- def to_json(*a)
- to_s.to_json(*a)
- end
-end
-
-module Enumerable
- def to_json(*a)
- to_a.to_json(*a)
- end
-end
-
-# class Regexp
-# def to_json(*)
-# inspect
-# end
-# end
-#
-# The above rails definition has some problems:
-#
-# 1. { 'foo' => /bar/ }.to_json # => "{foo: /bar/}"
-# This isn't valid JSON, because the regular expression syntax is not
-# defined in RFC 4627. (And unquoted strings are disallowed there, too.)
-# Though it is valid Javascript.
-#
-# 2. { 'foo' => /bar/mix }.to_json # => "{foo: /bar/mix}"
-# This isn't even valid Javascript.
-