From: Brian Candler Date: 2011-02-10T06:00:39+09:00 Subject: Re: Best practice to create a JSON string of one object containing an array of other objects using R Matthias S. wrote in post #980645: > @Brian: Both approaches you proposed result in IOError exception in > class A, saying to_json "not opened for reading". Can you paste the *exact* exception you see, and the exact code which triggers it? Plus details of the platform you are on. It works for me: $ ruby -v ruby 1.8.7 (2010-06-23 patchlevel 299) [x86_64-linux] $ ruby ert.rb # {"a":[123,456],"json_class":"A"} # That's running the code I posted, just with the addition of require 'rubygems' require 'json' # also works with require 'json/pure' at the top. I have the json-1.4.3 gem installed, and json_pure-1.4.3. Regards, Brian. -- Posted via http://www.ruby-forum.com/.