Jeremy Kemper
49824e8ad6
JSON.escape returns UTF-8 strings
...
[#2849 state:resolved]
2009-07-01 16:22:19 -07:00
Jeremy Kemper
f37a2ea84c
uses Hash#except/slice
2009-07-01 16:01:20 -07:00
Joshua Peek
fbdf706fff
Add basic JSON serializer to AMo
2009-06-17 21:27:54 -05:00
Jeremy Kemper
e1f679a020
Simplify json decoder backend lazy load
2009-06-08 19:37:51 -07:00
Jeremy Kemper
30a3b6b4fc
Ruby 1.9: fix json encoding
2009-06-08 15:16:47 -07:00
Jeremy Kemper
00ee990443
JSON: split encoding and coercion
2009-06-08 13:21:30 -07:00
rick
e89241c92f
load the JSON Backend lazily. If the JSON gem is already loaded, use the JSONGem backend by default.
2009-05-17 19:18:00 -07:00
Brian Lopez
53dda29f8b
Add support for parsing XML and JSON from an IO as well as a string [ #2659 state:resolved]
...
Signed-off-by: Joshua Peek <josh@joshpeek.com >
2009-05-17 10:37:52 -05:00
Jeremy Kemper
f58c322e7e
Use __send__ for BasicObject friendliness
2009-04-26 20:05:17 -07:00
Jeremy Kemper
ee46ffedb8
Now that we have a separate internal rails_to_json, use a separate circular reference stack instead of sticking it in the options hash
2009-04-26 20:04:47 -07:00
Jeremy Kemper
3bd32754e2
Privatize rails_to_json
2009-04-26 15:54:28 -07:00
Jeremy Kemper
4a8d2ef0a5
Extract json string escaping
2009-04-26 15:53:59 -07:00
Jeremy Kemper
8d64085138
Only Object to_json alias is needed. Prefer nil options.
2009-04-26 15:18:33 -07:00
Jeremy Kemper
da3a80dd4f
Track object ids so the objects needn't respond to ==
2009-04-26 15:04:02 -07:00
rick
3c4c6bd0df
* Add pluggable JSON backends with support for the JSON gem. [rick]
...
Example: ActiveSupport::JSON.backend = "JSONGem"
All internal Rails JSON encoding is now handled by ActiveSupport::JSON.encode(). Use of #to_json is not recommended, as it may clash with other libraries that overwrite it. However, you can recover Rails specific functionality
if you really want to use #to_json.
gem 'json'
ActiveSupport::JSON.backend = "JSONGem"
class ActiveRecord::Base
alias to_json rails_to_json
end
2009-04-23 00:08:40 -07:00
Jeremy Kemper
f28bd9557c
Fix dependencies revealed by testing in isolation
2009-04-22 18:54:13 -07:00
Jeremy Kemper
42a06d2d62
stdlib autoloads were hanging on 1.9.1
2009-04-22 09:10:48 -07:00
Jeremy Kemper
f40eb52566
Autoload YAML and StringScanner for JSON decoding
2009-04-17 22:24:08 -07:00
Jeremy Kemper
cb5b2ca5c1
Explicit dependency on Object#instance_values extension
2009-03-28 23:52:15 -07:00
Jeremy Kemper
b4af87317b
Explicit dependency on Array#wrap extension
2009-03-28 23:51:37 -07:00
Jeremy Kemper
d41387fde7
Explicit dependency on String#start_with? extension
2009-03-28 23:51:20 -07:00
Ubiratan Pires Alberton
7b382cb9e5
Reverted affe50105f and added more JSON decoding tests.
...
Works on Ruby 1.8 and 1.9
[#1100 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2009-03-11 14:36:14 -07:00
Pratik Naik
affe50105f
Remove untested part from 9b9b2937ce
2009-03-10 18:16:10 +00:00
Tim Pope
9b9b2937ce
Properly decode \u escape sequences in JSON [ #1100 state:resolved] [Tim Pope, Philip Hallstrom]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com >
2009-03-10 17:05:17 +00:00
Akira Matsuda
7c0e008973
Ruby 1.9 compat: fix JSON decoding to work properly with multibyte values
...
[#1969 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2009-02-17 11:58:53 -08:00
Jeremy Kemper
5f56d90085
Use Array.wrap, remove unneeded returning block
2009-02-06 10:05:16 -08:00
Pratik Naik
39e1ac658e
Merge docrails
2009-01-18 18:10:58 +00:00
Michael Koziarski
0bed5bdb21
Properly quote json keys.
...
According to the RFC and the json.org site all json keys must be strings, and those strings must be quoted with double quotes.
[#1755 state:committed]
2009-01-16 17:40:04 +13:00
Pratik Naik
17da45b789
Fix JSON decoder date-converter regexp [ #1662 state:resolved] [Jonathan del Strother]
2009-01-07 17:51:11 +00:00
Jeremy Kemper
6599dd907f
Simpler and clearer to just explicitly require the JSON encoders
2008-11-26 01:08:37 -08:00
Jeremy Kemper
e9aa975cc9
Eliminate thread-local circular reference stack by passing it as an argument instead
2008-11-23 12:36:03 -08:00
Pratik Naik
0432d15164
Merge with docrails.
2008-07-16 13:01:23 +01:00
Pratik Naik
9783e66cad
Slightly faster DateTime#to_json. [ #598 state:resolved] [Alex Zepeda]
2008-07-14 01:02:07 +01:00
Pratik Naik
98dc582742
Merge docrails.
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com >
2008-05-25 12:29:00 +01:00
gbuesing
be85868987
Time#to_json: don't convert to utc before encoding. References #175
2008-05-18 10:48:11 -05:00
Rick Olson
605196c448
Add config.active_support.escape_html_entities_in_json to allow disabling of html entity escaping. [rick]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9238 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-04-08 03:45:26 +00:00
Rick Olson
1eb57a6870
Add config.active_support.use_standard_json_time_format setting so that Times and Dates export to ISO 8601 dates. [rick]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9203 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-04-01 20:25:26 +00:00
Josh Peek
eece9b4e8a
Force json string encoding to ASCII-8BIT before unpacking for Ruby 1.9.
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9138 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-03-29 21:48:08 +00:00
Pratik Naik
ca9413674e
Improve documentation.
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9093 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-03-26 12:27:52 +00:00
Geoff Buesing
abb24b484f
Adding Time and DateTime #formatted_offset, for outputting +HH:MM utc offset strings with cross-platform consistency
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8698 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-01-23 02:46:47 +00:00
Geoff Buesing
772ad95201
Time#to_json uses Numeric#to_utc_offset_s to output cross-platform-consistent representation without having to convert to DateTime. References #9750
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8636 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-01-12 21:02:46 +00:00
Rick Olson
9e2536393e
remove multiple enumerations from ActiveSupport::JSON#convert_json_to_yaml when dealing with date/time values. [rick]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8505 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2007-12-28 18:37:17 +00:00
Michael Koziarski
92f02adf40
Don't escape forward slashes with String#to_json, our unicode encoding of < and > prevent the XSS problems. [tpope] Closes #10273
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8255 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2007-12-02 08:45:35 +00:00
Rick Olson
c708346688
Change JSON to encode %w(< > &) as 4 digit hex codes to be in compliance with the JSON spec. Closes #9975 [josh, chuyeow, tpope]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8050 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2007-10-29 00:18:43 +00:00
Rick Olson
34c125d774
Fix JSON encoding/decoding bugs dealing with /'s. Closes #9990 [Rick, theamazingrando]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8026 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2007-10-26 03:22:02 +00:00
Michael Koziarski
192e463d05
Add an ignored options parameter to ActiveSupport::JSON::Variable#to_json to make sure it duck-types nicely with the other JSON types. [Pascal Belloncle]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8013 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2007-10-25 07:09:09 +00:00
Jeremy Kemper
7c3581cba2
Document Enumerable and Hash #to_json. Add test for hash with integer key. Closes #9970 .
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8010 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2007-10-24 16:21:46 +00:00
Jeremy Kemper
003df72d00
Don't shadow local var with block var
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7865 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2007-10-13 21:41:56 +00:00
Jeremy Kemper
58a5eef53e
Disambiguate Time, Date, and DateTime#to_json formatting. Closes #9750 .
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7746 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2007-10-05 09:43:24 +00:00
Jeremy Kemper
b1968708e1
Hash#to_json takes :only or :except options to specific or omit certain hash keys. Enumerable#to_json passes through its options to each element. Closes #9751 .
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7736 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2007-10-04 03:28:42 +00:00