aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/json/encoding.rb
Commit message (Collapse)AuthorAgeFilesLines
* Remove active_support/json/variable was deprecated.kennyj2013-06-011-1/+0
|
* Merge pull request #10534 from cmaruz/masterRafael Mendonça França2013-05-101-1/+4
|\ | | | | | | | | | | | | Escape of U+2028 and U+2029 in the JSON Encoder Conflicts: activesupport/lib/active_support/json/encoding.rb
| * Added escaping of U+2028 and U+2029 inside the json encoder.Mario Caropreso2013-05-091-3/+6
| | | | | | | | | | | | | | | | | | | | | | 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
* | Fix syntax error on Ruby 2.0Rafael Mendonça França2013-05-101-2/+4
| | | | | | | | | | Since Ruby 2.0 is UTF-8 by default we need to explictly say that the encoding of this file is US-ASCII
* | Escape multibyte line terminators in JSON encodingzackham2013-04-021-2/+4
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, json/encoding respects the JSON spec (as it should) which disallows \n and \r inside strings, escaping them as expected. Unfortunately, ECMA-262 (Javascript) disallows not only \n and \r in strings, but "Line Terminators" which includes U+2028 and U+2029. See here: http://bclary.com/2004/11/07/#a-7.3 This pull request adds U+2028 and U+2029 to be escaped. # Why?  It's very common to see something like this in a Rails template: <script type="text/javascript">  var posts = <%= @posts.to_json %>; </script> If U+2028 or U+2029 are part of any attributes output in the to_json call, you will end up with an exception. In Chrome: Uncaught SyntaxError: Unexpected token ILLEGAL  # Why not? This is JSON encoding, and the JSON spec is specific about how to  encode strings. U+2028 and U+2029 don't get special treatment. Just trying to start a discussion... what do you do in your apps to deal with this? Is there a convention I'm missing?
* Revert "Simplify code in AS json encoder"Guillermo Iguaran2013-02-251-8/+15
| | | | | | This reverts commit 046e27a7338f2961c10e9d133e0e2229b51c2ba8. Check https://github.com/rails/rails/pull/8815#issuecomment-14026122 for details.
* Merge pull request #8815 from bogdan/simplified-to-json-argsSteve Klabnik2013-02-241-15/+8
|\ | | | | AS JSON encoder: remove monkey patch of Array
| * Simplify code in AS json encoderBogdan Gusiev2013-01-061-15/+8
| |
* | prefer american spelling of 'behavior'Gosha Arinich2013-01-071-1/+1
|/
* Remove unicode character encoding from ActiveSupport::JSON.encodeBrett Carter2012-12-141-7/+1
| | | | | | | | | | 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.
* `#as_json` isolates options when encoding a hash. Closes #8182Yves Senn2012-11-121-1/+1
| | | | | | Setting options in a custom `#as_json` method had side effects. Modifications of the `options` hash leaked outside and influenced the conversion of other objects contained in the hash.
* update AS/json docs [ci skip]Francesco Rodriguez2012-09-141-10/+16
|
* Add back missing requireRafael Mendonça França2012-08-071-0/+1
|
* fixing :nodoc:s in AS::JSON::EncodingFrancesco Rodriguez2012-07-211-15/+48
|
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-06-021-1/+1
|\
| * Fix typo [ci skip]Erich Menge2012-05-301-1/+1
| |
* | Merge pull request #6554 from erichmenge/remove-json-variablePiotr Sarnacki2012-05-301-1/+0
|\ \ | |/ |/| Remove deprecated ActiveSupport::JSON::Variable.
| * Remove deprecated ActiveSupport::JSON::Variable.Erich Menge2012-05-301-1/+0
| |
* | Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-05-301-1/+4
|\ \ | |/ |/|
| * add example to ActiveSupport::JSON.encode [ci skip]Francesco Rodriguez2012-05-281-1/+4
| |
* | True, False, and Nil should be represented in as_json as themselves.Erich Menge2012-05-291-9/+9
|/
* Since escape_html_entities_in_json was moved to 3-2-stable, make it true in ↵José Valim2012-05-141-1/+1
| | | | AS, closes #6287
* BigDecimal string wrapping in JSON serialization can now be opted-out, fixes ↵David FRANCOIS2012-05-021-1/+14
| | | | #6033
* JSON: encode BigDecimal NaN/Infinity as null.Sebi Burkhard2012-05-011-1/+3
|
* Merge pull request #2532 from ↵Piotr Sarnacki2012-04-301-0/+4
|\ | | | | | | | | hasclass/as_json__encode_infinite_and_nan_floats_as_null JSON: Encode infinite or NaN floats as `null` to generate valid JSON.
| * JSON: Encode infinite or NaN floats as null to generate valid JSON.Sebi Burkhard2011-08-151-0/+4
| |
* | Replaced OrderedHash usage with Ruby 1.9 HashUddhava2012-02-091-3/+1
| |
* | fixes in api docsVijay Dev2012-01-131-2/+2
| |
* | Remove Array.wrap calls in ActiveSupportRafael Mendonça França2012-01-061-3/+2
| |
* | use #to_s to convert Range to jsonSergey Nartimov2012-01-011-0/+4
| |
* | remove checks for encodings availabilitySergey Nartimov2011-12-251-5/+3
| |
* | Revert "Implement ArraySerializer and move old serialization API to a new ↵José Valim2011-11-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | namespace." This reverts commit 8896b4fdc8a543157cdf4dfc378607ebf6c10ab0. Conflicts: activemodel/lib/active_model.rb activemodel/lib/active_model/serializable.rb activemodel/lib/active_model/serializer.rb activemodel/test/cases/serializer_test.rb
* | Implement ArraySerializer and move old serialization API to a new namespace.José Valim2011-11-231-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | The following constants were renamed: ActiveModel::Serialization => ActiveModel::Serializable ActiveModel::Serializers::JSON => ActiveModel::Serializable::JSON ActiveModel::Serializers::Xml => ActiveModel::Serializable::XML The main motivation for such a change is that `ActiveModel::Serializers::JSON` was not actually a serializer, but a module that when included allows the target to be serializable to JSON. With such changes, we were able to clean up the namespace to add true serializers as the ArraySerializer.
* | Set the default options value for as_json in the encoder object.José Valim2011-09-301-2/+2
|/
* Removed deprecated methods and related tests from ActiveSupportJosh Kalderimis2011-05-251-3/+0
|
* Use set data structure to speed up circular reference checks on large/deeply ↵Andy Lindeman2011-05-231-4/+4
| | | | nested objects
* add missing require for ordered_hash dependencyCorin Langosch2011-05-111-0/+1
|
* Enumerable should pass encoding options to children in #as_json/#to_json.John Firebaugh2011-04-011-1/+3
|
* Updated the json date regex to recognize xmlschema formatted date times ↵Josh Kalderimis2011-02-121-1/+1
| | | | | | during json decoding. [#3031 state:resolved] Signed-off-by: Santiago Pastorino and Emilio Tagua <santiago+emilioe@wyeworks.com>
* Complex struct encoding fixAlexey Nayden2011-01-151-0/+6
| | | | | | [#6077 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Perf: speed up json encoding.Emilio Tagua2010-09-221-3/+2
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* fixed some issues with JSON encodingJakub Suder2010-09-071-6/+44
| | | | | | | | | | | - as_json in ActiveModel should return a hash and handle :only/:except/:methods options - Array and Hash should call as_json on their elements - json methods should not modify options argument [#5374 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* Move Date#xmlschema to conversions and add a missing requireSantiago Pastorino2010-07-041-0/+2
|
* Time#formatted_offset is defined in core_ext/time/conversionsSantiago Pastorino2010-07-021-0/+1
| | | | [#4979]
* Time#as_json: use Time#formatted_offset instead of strftime %z directive, ↵Geoff Buesing2010-07-021-1/+1
| | | | | | | | which is non-standard and inaccurate on some platforms (e.g., Mac OS X). [#4979] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* Time has it own implementation of xmlschema, now AMo doesn't depend on TZInfoSantiago Pastorino2010-07-021-2/+2
| | | | | | [#4979 state:committed] Signed-off-by: José Valim <jose.valim@gmail.com>
* AS json refactor, move to_json implementation to core_ext and a cleanup a ↵Santiago Pastorino2010-07-011-31/+6
| | | | bit the code
* Work around the fact the JSON gem was overwriting to_json implementation for ↵José Valim2010-06-261-5/+14
| | | | | | | all Ruby core classes. This is required because the JSON gem is incompatible with Rails behavior and was not allowing ActiveModel::Errors to be serialized. So we need to ensure Rails implementation is the one triggered. [#4890 state:resolved]
* adds a comment explaining why BigDecimal#as_json returns a JSON stringXavier Noria2010-05-031-1/+9
|
* Missing require added make pass activesupport/test/json/encoding_test.rb in ↵Santiago Pastorino2010-05-021-0/+1
| | | | | | isolation Signed-off-by: Xavier Noria <fxn@hashref.com>