Created
August 5, 2011 19:10
-
-
Save pzol/1128267 to your computer and use it in GitHub Desktop.
ActiveSupport broken on UTF-8 strings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: UTF-8 | |
# parsing with EOF throws illegal characters!? | |
json = <<EOF | |
{ | |
"date_a": "2011-07-22T09:54:44Z", | |
"city": "wroc\u0142aw", # after this the next date is not parsed anymore! | |
"date_b": "2011-07-22T09:54:44Z" | |
} | |
EOF | |
# this json works | |
json2 = ' { "date_a": "2011-07-22T09:54:44Z", "city": "wroc\u0142aw", "date_b": "2011-07-22T09:54:44Z" }' | |
require 'active_support/json' | |
require 'oj' | |
ActiveSupport.parse_json_times = true | |
p ActiveSupport::JSON.backend | |
p ActiveSupport::JSON.decode(json2) |
It parses date value into ruby DateTime object which is invalid for mongodb ruby driver.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
activesupport (3.0.9)