Decoding JSON dates should respect newlines
This commit is contained in:
parent
6bc7c478ba
commit
e2a2ee008b
|
@ -10,8 +10,8 @@ module ActiveSupport
|
|||
|
||||
module JSON
|
||||
# matches YAML-formatted dates
|
||||
DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/
|
||||
DATETIME_REGEX = /^(?:\d{4}-\d{2}-\d{2}|\d{4}-\d{1,2}-\d{1,2}[T \t]+\d{1,2}:\d{2}:\d{2}(\.[0-9]*)?(([ \t]*)Z|[-+]\d{2}?(:\d{2})?)?)$/
|
||||
DATE_REGEX = /\A\d{4}-\d{2}-\d{2}\z/
|
||||
DATETIME_REGEX = /\A(?:\d{4}-\d{2}-\d{2}|\d{4}-\d{1,2}-\d{1,2}[T \t]+\d{1,2}:\d{2}:\d{2}(\.[0-9]*)?(([ \t]*)Z|[-+]\d{2}?(:\d{2})?)?)\z/
|
||||
|
||||
class << self
|
||||
# Parses a JSON string (JavaScript Object Notation) into a hash.
|
||||
|
|
|
@ -40,6 +40,8 @@ class TestJSONDecoding < ActiveSupport::TestCase
|
|||
# needs to be *exact*
|
||||
%({"a": " 2007-01-01 01:12:34 Z "}) => { "a" => " 2007-01-01 01:12:34 Z " },
|
||||
%({"a": "2007-01-01 : it's your birthday"}) => { "a" => "2007-01-01 : it's your birthday" },
|
||||
%({"a": "Today is:\\n2020-05-21"}) => { "a" => "Today is:\n2020-05-21" },
|
||||
%({"a": "2007-01-01 01:12:34 Z\\nwas my birthday"}) => { "a" => "2007-01-01 01:12:34 Z\nwas my birthday" },
|
||||
%([]) => [],
|
||||
%({}) => {},
|
||||
%({"a":1}) => { "a" => 1 },
|
||||
|
|
Loading…
Reference in New Issue