1. 13 9月, 2013 1 次提交
    • G
      Moved all JSON core extensions into core_ext/object/json · 64c88fb5
      Godfrey Chan 提交于
      TL;DR The primary driver is to remove autoload surprise.
      
      This is related to #12106. (The root cause for that ticket is that
      json/add defines Regexp#to_json among others, but here I'll reproduce
      the problem without json/add.)
      
      Before:
      
         >> require 'active_support/core_ext/to_json'
         => true
         >> //.as_json
         NoMethodError: undefined method `as_json' for //:Regexp
           from (irb):3
           from /Users/godfrey/.rvm/rubies/ruby-2.0.0-p195/bin/irb:16:in `<main>'
         >> //.to_json
         => "\"(?-mix:)\""
         >> //.as_json
         => "(?-mix:)"
      
      After:
      
         >> require 'active_support/core_ext/to_json'
         => true
         >> //.as_json
         => "(?-mix:)"
      
      This is because ActiveSupport::JSON is autoloaded the first time
      Object#to_json is called, which causes additional core extentions
      (previously defined in active_support/json/encoding.rb) to be loaded.
      
      When someone require 'active_support/core_ext', the expectation is
      that it would add certain methods to the core classes NOW. The
      previous behaviour causes additional methods to be loaded the first
      time you call `to_json`, which could cause nasty surprises and other
      unplesant side-effects.
      
      This change moves all core extensions in to core_ext/json. AS::JSON is
      still autoloaded on first #to_json call, but since it nolonger
      include the core extensions, it should address the aforementioned bug.
      
      *Requiring core_ext/object/to_json now causes a deprecation warnning*
      64c88fb5
  2. 01 6月, 2013 1 次提交
  3. 26 5月, 2013 1 次提交
  4. 09 5月, 2013 1 次提交
    • M
      Added escaping of U+2028 and U+2029 inside the json encoder. · 582b4417
      Mario Caropreso 提交于
      U+2028 and U+2029 are allowed inside strings in JSON (as all literal
      Unicode characters) but JavaScript defines them as newline
      seperators. Because no literal newlines are allowed in a string, this
      causes a ParseError in the browser. We work around this issue by
      replacing them with the escaped version. The resulting JSON is still
      valid and can be parsed in the browser.
      
      This commit has been coauthored with Viktor Kelemen @yikulju
      582b4417
  5. 04 5月, 2013 1 次提交
  6. 28 12月, 2012 1 次提交
  7. 15 12月, 2012 1 次提交
    • B
      Remove unicode character encoding from ActiveSupport::JSON.encode · 8f8397e0
      Brett Carter 提交于
      The encoding scheme (e.g.  -> "\u2620") was broken for characters
      not in the Basic Multilingual Plane.  It is possible to escape them
      for json using the weird encoding scheme of a twelve-character
      sequence representing the UTF-16 surrogate pair (e.g. '𠜎' ->
      "\u270e\u263a") but this wasn't properly handled in the escaping code.
      Since raw UTF-8 is allowed in json, it was decided to simply pass
      through the raw bytes rather than attempt to escape them.
      8f8397e0
  8. 12 11月, 2012 1 次提交
  9. 08 8月, 2012 1 次提交
    • E
      Deprecate ActiveSupport::JSON::Variable · 83f2ffcf
      Erich Menge 提交于
      Reason: ActiveSupport::JSON::Variable is not used anymore internally. It
      was deprecated in 3-2-stable but we reverted all the deprecation for
      point releases.
      
      See #6536 and #6546.
      Conflicts:
      	activesupport/lib/active_support/json/variable.rb
      83f2ffcf
  10. 31 5月, 2012 1 次提交
  11. 30 5月, 2012 1 次提交
  12. 02 5月, 2012 1 次提交
  13. 01 5月, 2012 1 次提交
  14. 06 1月, 2012 1 次提交
  15. 02 1月, 2012 1 次提交
  16. 25 12月, 2011 1 次提交
  17. 21 12月, 2011 1 次提交
  18. 15 8月, 2011 1 次提交
  19. 02 4月, 2011 1 次提交
  20. 18 1月, 2011 1 次提交
  21. 15 1月, 2011 1 次提交
  22. 12 1月, 2011 1 次提交
  23. 08 9月, 2010 1 次提交
  24. 24 7月, 2010 1 次提交
  25. 02 7月, 2010 1 次提交
  26. 04 5月, 2010 1 次提交
  27. 29 4月, 2010 1 次提交
  28. 27 4月, 2010 1 次提交
  29. 11 2月, 2010 1 次提交
  30. 24 12月, 2009 1 次提交
  31. 02 7月, 2009 1 次提交
  32. 09 6月, 2009 1 次提交
  33. 27 4月, 2009 1 次提交
  34. 23 4月, 2009 1 次提交
    • R
      * Add pluggable JSON backends with support for the JSON gem. [rick] · 3c4c6bd0
      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
      3c4c6bd0
  35. 29 3月, 2009 1 次提交
  36. 09 3月, 2009 1 次提交
  37. 16 1月, 2009 1 次提交
    • M
      Properly quote json keys. · 0bed5bdb
      Michael Koziarski 提交于
      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]
      0bed5bdb
  38. 23 11月, 2008 1 次提交
  39. 13 10月, 2008 1 次提交
  40. 21 9月, 2008 1 次提交