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 #1

Updated by yugui (Yuki Sonoda) about 13 years ago

  • Assignee set to tenderlovemaking (Aaron Patterson)

=begin

=end

Actions #2

Updated by yugui (Yuki Sonoda) about 13 years ago

  • Status changed from Open to Assigned
  • Priority changed from 3 to Normal

=begin

=end

Actions #3

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

Also available in: Atom PDF

Like0
Like0Like0Like0