Actions
Bug #4244
closedPsych.to_json generate incorrect JSON
Description
=begin
Psych.to_json could be presumed to return JSON because of its name.
But Psych.to_json generate single-quoted string. It isn't valid JSON format.
require "psych"
=> true
Psych.to_json("aaa")
=> "'aaa'\n"
Psych.to_json(["a","b","c"])
=> "['a', 'b', 'c']\n"
require "json"
=> true
JSON.parse(Psych.to_json(["a","b","c"]))
JSON::ParserError: 376: unexpected token at ''a', 'b', 'c']
'
=end
Updated by yugui (Yuki Sonoda) about 13 years ago
- Assignee set to tenderlovemaking (Aaron Patterson)
=begin
=end
Updated by yugui (Yuki Sonoda) about 13 years ago
- Status changed from Open to Assigned
- Priority changed from 3 to Normal
=begin
=end
Updated by Anonymous about 13 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
=begin
This issue was solved with changeset r30587.
Tomoyuki, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- ext/psych/lib/psych/visitors/json_tree.rb (visit_String): JSON
strings should be dumped with double quotes. [ruby-core:34186] - test/psych/test_json_tree.rb: test for double quotes
=end
Actions
Like0
Like0Like0Like0