From 27be3056dc0e9c313f25b430ca90b240a5e44160 Mon Sep 17 00:00:00 2001 From: usa Date: Mon, 26 Apr 2010 04:34:36 +0000 Subject: * ext/jason: revert r27493. came again after canceling gcc-ism. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/json/lib/json/add/core.rb | 27 +++++++-------------------- ext/json/lib/json/add/rails.rb | 4 ++-- 2 files changed, 9 insertions(+), 22 deletions(-) (limited to 'ext/json/lib/json/add') diff --git a/ext/json/lib/json/add/core.rb b/ext/json/lib/json/add/core.rb index 03a00dded4..4423e7ad75 100644 --- a/ext/json/lib/json/add/core.rb +++ b/ext/json/lib/json/add/core.rb @@ -7,19 +7,6 @@ unless Object.const_defined?(:JSON) and ::JSON.const_defined?(:JSON_LOADED) and end require 'date' -class Symbol - def to_json(*a) - { - JSON.create_id => self.class.name, - 's' => to_s, - }.to_json(*a) - end - - def self.json_create(o) - o['s'].to_sym - end -end - class Time def self.json_create(object) if usec = object.delete('u') # used to be tv_usec -> tv_nsec @@ -34,7 +21,7 @@ class Time def to_json(*args) { - JSON.create_id => self.class.name, + 'json_class' => self.class.name, 's' => tv_sec, 'n' => respond_to?(:tv_nsec) ? tv_nsec : tv_usec * 1000 }.to_json(*args) @@ -50,7 +37,7 @@ class Date def to_json(*args) { - JSON.create_id => self.class.name, + 'json_class' => self.class.name, 'y' => year, 'm' => month, 'd' => day, @@ -76,7 +63,7 @@ class DateTime def to_json(*args) { - JSON.create_id => self.class.name, + 'json_class' => self.class.name, 'y' => year, 'm' => month, 'd' => day, @@ -96,7 +83,7 @@ class Range def to_json(*args) { - JSON.create_id => self.class.name, + 'json_class' => self.class.name, 'a' => [ first, last, exclude_end? ] }.to_json(*args) end @@ -111,7 +98,7 @@ class Struct klass = self.class.name klass.to_s.empty? and raise JSON::JSONError, "Only named structs are supported!" { - JSON.create_id => klass, + 'json_class' => klass, 'v' => values, }.to_json(*args) end @@ -126,7 +113,7 @@ class Exception def to_json(*args) { - JSON.create_id => self.class.name, + 'json_class' => self.class.name, 'm' => message, 'b' => backtrace, }.to_json(*args) @@ -140,7 +127,7 @@ class Regexp def to_json(*) { - JSON.create_id => self.class.name, + 'json_class' => self.class.name, 'o' => options, 's' => source, }.to_json diff --git a/ext/json/lib/json/add/rails.rb b/ext/json/lib/json/add/rails.rb index 8ce85efe57..e86ed1aab9 100644 --- a/ext/json/lib/json/add/rails.rb +++ b/ext/json/lib/json/add/rails.rb @@ -10,7 +10,7 @@ class Object def self.json_create(object) obj = new for key, value in object - next if key == JSON.create_id + next if key == 'json_class' instance_variable_set "@#{key}", value end obj @@ -18,7 +18,7 @@ class Object def to_json(*a) result = { - JSON.create_id => self.class.name + 'json_class' => self.class.name } instance_variables.inject(result) do |r, name| r[name[1..-1]] = instance_variable_get name -- cgit v1.2.3