Commit Graph

106 Commits

Author SHA1 Message Date
José Valim
37b9594a8e Set the default options value for as_json in the encoder object. 2011-09-30 12:45:36 +02:00
Josh Kalderimis
9cafc28874 Removed deprecated methods and related tests from ActiveSupport 2011-05-25 23:39:34 +02:00
Andy Lindeman
2213479a12 Use set data structure to speed up circular reference checks on large/deeply nested objects 2011-05-23 17:50:48 -04:00
Corin Langosch
295bf413e5 add missing require for ordered_hash dependency 2011-05-11 16:22:35 +02:00
José Valim
a761d77902 Merge pull request #248 from bigfix/enumerable_as_json
Enumerable should pass encoding options to children in #as_json/#to_json
2011-05-07 03:19:56 -07:00
Josh Kalderimis
1d8be7bc6f AS Json parse_error makes a return for backwards compatibility, although it will return MultiJson::DecodeError 2011-04-19 00:01:50 +02:00
Josh Kalderimis
e019587e31 removed AS backends and instead rely on MultiJson for json decoding 2011-04-18 21:39:15 +02:00
John Firebaugh
080e2a7abf Enumerable should pass encoding options to children in #as_json/#to_json. 2011-04-01 12:16:54 -07:00
Diego Carrion
a1edbf7206 parse dates to yaml in json arrays
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-03-22 21:09:54 -03:00
Diego Carrion
7004434ad8 test json decoding with time parsing disabled with all backends and respect ActiveSupport.parse_json_times when converting to yaml
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-03-22 21:09:54 -03:00
Josh Kalderimis
e8c870726a Updated the json date regex to recognize xmlschema formatted date times during json decoding. [#3031 state:resolved]
Signed-off-by: Santiago Pastorino and Emilio Tagua <santiago+emilioe@wyeworks.com>
2011-02-12 13:30:30 -02:00
Josh Kalderimis
b17d8d727f Fixes an issue when decoding a json string which looks like a date but is invalid. This DateTime parse error is now caught and the original string is instead passed back [#6286 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-11 13:54:57 -02:00
Maxime RETY
68e3fb8109 Fix JSON decoding of newline character with Yaml backend [#3479 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-02 18:57:48 -02:00
Aaron Patterson
370bcd1a01 use ! " " YAML string literal syntax rather than removing both quotes 2011-01-21 14:09:59 -08:00
Alexey Nayden
a9163b547c Complex struct encoding fix
[#6077 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-01-15 00:06:26 -02:00
Aaron Patterson
7bd32e4d1d add Psych::SyntaxError to the list of rescued YAML exceptions 2011-01-04 16:52:47 -08:00
Emilio Tagua
7047d83ec5 Perf: speed up json encoding.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-22 18:08:04 -03:00
Jakub Suder
2524cf404c fixed some issues with JSON encoding
- 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>
2010-09-07 11:33:10 -07:00
Santiago Pastorino
e1d4e78b15 Removes unused vars
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-24 01:19:44 +02:00
Santiago Pastorino
5bf3294c8b Move Date#xmlschema to conversions and add a missing require 2010-07-04 14:10:28 -07:00
Santiago Pastorino
8cc746331c Time#formatted_offset is defined in core_ext/time/conversions
[#4979]
2010-07-02 20:22:35 -07:00
Geoff Buesing
227e1caea5 Time#as_json: use Time#formatted_offset instead of strftime %z directive, which is non-standard and inaccurate on some platforms (e.g., Mac OS X).
[#4979]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-07-02 11:50:16 -07:00
Santiago Pastorino
cb321546b7 Time has it own implementation of xmlschema, now AMo doesn't depend on TZInfo
[#4979 state:committed]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-02 01:51:03 +02:00
Santiago Pastorino
4a0c514eb4 AS json refactor, move to_json implementation to core_ext and a cleanup a bit the code 2010-07-01 12:04:11 -07:00
José Valim
7bd85a8fc2 Work around the fact the JSON gem was overwriting to_json implementation for 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]
2010-06-26 12:01:13 +02:00
Maxime RETY
2c2a5fe829 Fix Yajl backend discovery in ActiveSupport::JSON
[#4897 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-06-18 20:12:31 -07:00
Santiago Pastorino
b514b4d696 removes spurious .rb in require
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-06-13 13:56:08 +02:00
Xavier Noria
9e085a9f33 adds a comment explaining why BigDecimal#as_json returns a JSON string 2010-05-03 22:04:47 +02:00
Santiago Pastorino
02028e529c Missing require added make pass activesupport/test/json/encoding_test.rb in isolation
Signed-off-by: Xavier Noria <fxn@hashref.com>
2010-05-02 22:05:40 +02:00
Xavier Noria
1d63129eff use ordinary syntax for options to be well-formed in 1.8 2010-04-27 02:36:34 -07:00
Jeremy Kemper
c1d7327071 JSON: encode objects that don't have a native JSON representation using to_hash, if available, instead of instance_values (the old fallback) or to_s (other encoders' default). Encode BigDecimal and Regexp encode as strings to conform with other encoders. Try to transcode non-UTF-8 strings. 2010-04-26 19:55:39 -07:00
Jeremy Kemper
a87683fb38 Disprefer JSONGem decoder since it only decodes JSON objects 2010-03-09 11:06:54 -08:00
Jeremy Kemper
63bb955a99 Automatically prefer Yajl or JSON backend over Yaml, if available 2010-02-05 10:22:45 -08:00
Brian Lopez
a96bf4ab5e Add yajl-ruby as a JSON parsing backend
[#2666 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-02-05 10:15:51 -08:00
David Heinemeier Hansson
6042067c0b Changed the default ActiveSupport.use_standard_json_time_format from false to true and
ActiveSupport.escape_html_entities_in_json from true to false to match previously announced Rails 3 defaults [DHH]
2010-01-03 19:20:43 -08:00
Dwayne Litzenberger
808cad2bb4 Fix ActiveSupport::JSON encoding of control characters [\x00-\x1f]
According to RFC 4627, only the following Unicode code points are
allowed unescaped in JSON:

  unescaped = %x20-21 / %x23-5B / %x5D-10FFFF

However, ActiveSupport::JSON did not escape the range %x00-1f.  This caused
parse errors when trying to decode the resulting output.

[#3345 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-12-23 11:46:06 -08:00
Jeremy Kemper
bc1538e995 Repair time dependencies 2009-11-14 11:37:06 -08:00
Jeremy Kemper
20cdaddfd2 Ruby 1.9.2: work around changes to flatten and nil.to_str 2009-11-08 22:02:57 -08:00
Jeremy Kemper
36a9644b86 Clarify date/time dependencies 2009-11-02 17:50:12 -08:00
Jeremy Kemper
053a0f6ac4 Clean up spurious JSON decoding test failure 2009-09-13 05:43:02 -07:00
Daniel Sheppard
b3381cacaf Fix that JSON parser fails to read escaped backslashes.
[#973 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-08-09 22:30:44 -07:00
Bas Van Klinkenberg
0fbeaa98e4 Fixed a bug in JSON decoding with Yaml backend, where a combination of dates, escaped or unicode encoded data and arrays would make the parser fail with a ParseError exception. [#2831 state:resolved]
Signed-off-by: Yehuda Katz <wycats@gmail.com>
2009-08-08 12:44:41 -03:00
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