Project

General

Profile

Actions

Bug #4244

closed

Psych.to_json generate incorrect JSON

Added by nagachika (Tomoyuki Chikanaga) about 13 years ago. Updated almost 13 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 1.9.3dev (2011-01-01 trunk 30447) [x86_64-darwin10.5.0]
Backport:
[ruby-core:34186]

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

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0