Forum: JRuby How to convert JavaObject to YAML format?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Hiroki K. (Guest)
on 2009-01-03 14:47
(Received via mailing list)
Hello,

I would like to store Java object to YAML format using JRuby.
I'll show you the code below.

### Java ###
public class LearinigJRubyAndJavaIntegration {
  public static void main(String[] args) throws Exception{
    BSFManager manager = new BSFManager();
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("name", "test");
    manager.registerBean("conf", map);
    InputStreamReader reader = new
InputStreamReader(LearningJRuby.class.getResource("write_yaml.rb").openStream());
    manager.exec("ruby", "(java)", -1, -1,
IOUtils.getStringFromReader(reader));
  }
}

### write_yaml.rb ###
require 'yaml'
require 'java'
conf = $bsf.lookupBean("conf")
puts YAML.dump(conf)

### provided ##
--- !ruby/object:Java::JavaUtil::HashMap
java_object: !ruby/object:Java::JavaObject {}

### Environment ###
JDK 1.5.0_16
OS: Linux
JRuby: 1.1.6

Is it possible to convert JavaObject to YAML format?

--
Hiroki K.
removed_email_address@domain.invalid

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
This topic is locked and can not be replied to.