Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
8d640851
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
8d640851
编写于
4月 26, 2009
作者:
J
Jeremy Kemper
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Only Object to_json alias is needed. Prefer nil options.
上级
be7e21a8
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
12 addition
and
35 deletion
+12
-35
actionpack/lib/action_view/helpers/prototype_helper.rb
actionpack/lib/action_view/helpers/prototype_helper.rb
+0
-2
activesupport/lib/active_support/json/encoders/date.rb
activesupport/lib/active_support/json/encoders/date.rb
+0
-2
activesupport/lib/active_support/json/encoders/date_time.rb
activesupport/lib/active_support/json/encoders/date_time.rb
+0
-2
activesupport/lib/active_support/json/encoders/enumerable.rb
activesupport/lib/active_support/json/encoders/enumerable.rb
+1
-3
activesupport/lib/active_support/json/encoders/false_class.rb
...vesupport/lib/active_support/json/encoders/false_class.rb
+0
-2
activesupport/lib/active_support/json/encoders/hash.rb
activesupport/lib/active_support/json/encoders/hash.rb
+7
-7
activesupport/lib/active_support/json/encoders/nil_class.rb
activesupport/lib/active_support/json/encoders/nil_class.rb
+0
-2
activesupport/lib/active_support/json/encoders/numeric.rb
activesupport/lib/active_support/json/encoders/numeric.rb
+0
-2
activesupport/lib/active_support/json/encoders/object.rb
activesupport/lib/active_support/json/encoders/object.rb
+1
-1
activesupport/lib/active_support/json/encoders/regexp.rb
activesupport/lib/active_support/json/encoders/regexp.rb
+0
-2
activesupport/lib/active_support/json/encoders/string.rb
activesupport/lib/active_support/json/encoders/string.rb
+0
-2
activesupport/lib/active_support/json/encoders/symbol.rb
activesupport/lib/active_support/json/encoders/symbol.rb
+1
-3
activesupport/lib/active_support/json/encoders/time.rb
activesupport/lib/active_support/json/encoders/time.rb
+0
-2
activesupport/lib/active_support/json/encoders/true_class.rb
activesupport/lib/active_support/json/encoders/true_class.rb
+0
-2
activesupport/lib/active_support/json/encoding.rb
activesupport/lib/active_support/json/encoding.rb
+2
-1
未找到文件。
actionpack/lib/action_view/helpers/prototype_helper.rb
浏览文件 @
8d640851
...
...
@@ -1188,8 +1188,6 @@ def rails_to_json(options = nil)
@variable
end
alias
to_json
rails_to_json
private
def
append_to_function_chain!
(
call
)
@generator
<<
@variable
if
@empty
...
...
activesupport/lib/active_support/json/encoders/date.rb
浏览文件 @
8d640851
...
...
@@ -18,6 +18,4 @@ def rails_to_json(options = nil)
%("#{strftime("%Y/%m/%d")}")
end
end
alias
to_json
rails_to_json
end
activesupport/lib/active_support/json/encoders/date_time.rb
浏览文件 @
8d640851
...
...
@@ -18,6 +18,4 @@ def rails_to_json(options = nil)
strftime
(
'"%Y/%m/%d %H:%M:%S %z"'
)
end
end
alias
to_json
rails_to_json
end
activesupport/lib/active_support/json/encoders/enumerable.rb
浏览文件 @
8d640851
...
...
@@ -6,9 +6,7 @@ module Enumerable
# # => users.to_json(:only => :name)
#
# will pass the <tt>:only => :name</tt> option to each user.
def
rails_to_json
(
options
=
{}
)
#:nodoc:
def
rails_to_json
(
options
=
nil
)
#:nodoc:
"[
#{
map
{
|
value
|
ActiveSupport
::
JSON
.
encode
(
value
,
options
)
}
* ','}]"
end
alias
to_json
rails_to_json
end
activesupport/lib/active_support/json/encoders/false_class.rb
浏览文件 @
8d640851
...
...
@@ -2,6 +2,4 @@ class FalseClass
def
rails_to_json
(
options
=
nil
)
#:nodoc:
'false'
end
alias
to_json
rails_to_json
end
activesupport/lib/active_support/json/encoders/hash.rb
浏览文件 @
8d640851
...
...
@@ -30,13 +30,15 @@ class Hash
# 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
=
{}
)
#:nodoc:
def
rails_to_json
(
options
=
nil
)
#:nodoc:
hash_keys
=
self
.
keys
if
except
=
options
[
:except
]
hash_keys
=
hash_keys
-
Array
.
wrap
(
except
)
elsif
only
=
options
[
:only
]
hash_keys
=
hash_keys
&
Array
.
wrap
(
only
)
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
=
'{'
...
...
@@ -45,6 +47,4 @@ def rails_to_json(options = {}) #:nodoc:
end
*
','
result
<<
'}'
end
alias
to_json
rails_to_json
end
activesupport/lib/active_support/json/encoders/nil_class.rb
浏览文件 @
8d640851
...
...
@@ -2,6 +2,4 @@ class NilClass
def
rails_to_json
(
options
=
nil
)
#:nodoc:
'null'
end
alias
to_json
rails_to_json
end
activesupport/lib/active_support/json/encoders/numeric.rb
浏览文件 @
8d640851
...
...
@@ -2,6 +2,4 @@ class Numeric
def
rails_to_json
(
options
=
nil
)
#:nodoc:
to_s
end
alias
to_json
rails_to_json
end
activesupport/lib/active_support/json/encoders/object.rb
浏览文件 @
8d640851
...
...
@@ -2,7 +2,7 @@
class
Object
# Dumps object in JSON (JavaScript Object Notation). See www.json.org for more info.
def
rails_to_json
(
options
=
{}
)
def
rails_to_json
(
options
=
nil
)
ActiveSupport
::
JSON
.
encode
(
instance_values
,
options
)
end
...
...
activesupport/lib/active_support/json/encoders/regexp.rb
浏览文件 @
8d640851
...
...
@@ -2,6 +2,4 @@ class Regexp
def
rails_to_json
(
options
=
nil
)
#:nodoc:
inspect
end
alias
to_json
rails_to_json
end
activesupport/lib/active_support/json/encoders/string.rb
浏览文件 @
8d640851
...
...
@@ -33,6 +33,4 @@ def rails_to_json(options = nil) #:nodoc:
s
.
unpack
(
"U*"
).
pack
(
"n*"
).
unpack
(
"H*"
)[
0
].
gsub
(
/.{4}/
,
'\\\\u\&'
)
}
+
'"'
end
alias
to_json
rails_to_json
end
activesupport/lib/active_support/json/encoders/symbol.rb
浏览文件 @
8d640851
class
Symbol
def
rails_to_json
(
options
=
{}
)
#:nodoc:
def
rails_to_json
(
options
=
nil
)
#:nodoc:
ActiveSupport
::
JSON
.
encode
(
to_s
,
options
)
end
alias
to_json
rails_to_json
end
activesupport/lib/active_support/json/encoders/time.rb
浏览文件 @
8d640851
...
...
@@ -20,6 +20,4 @@ def rails_to_json(options = nil)
%("#{strftime("%Y/%m/%d %H:%M:%S")} #{formatted_offset(false)}")
end
end
alias
to_json
rails_to_json
end
activesupport/lib/active_support/json/encoders/true_class.rb
浏览文件 @
8d640851
...
...
@@ -2,6 +2,4 @@ class TrueClass
def
rails_to_json
(
options
=
nil
)
#:nodoc:
'true'
end
alias
to_json
rails_to_json
end
activesupport/lib/active_support/json/encoding.rb
浏览文件 @
8d640851
...
...
@@ -4,7 +4,8 @@ class CircularReferenceError < StandardError
end
# Converts a Ruby object into a JSON string.
def
self
.
encode
(
value
,
options
=
{})
def
self
.
encode
(
value
,
options
=
nil
)
options
||=
{}
seen
=
(
options
[
:seen
]
||=
[])
raise
CircularReferenceError
,
'object references itself'
if
seen
.
include?
(
value
.
object_id
)
seen
<<
value
.
object_id
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录