in reply to From Perl to Java

...for instance what is the equivalent to 'Data::Dumper' ?

Not exactly equivalent... but when I feel like needing Data::Dumper in Java (to get an idea of what some complex data structure contains), I usually use XStream with the JSON backend (which I find a little easier on my eyes than the default XML representation).

The usual

use Data::Dumper; ... print Dumper $data;

then becomes something like

import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.io.json.JsonHierarchicalStreamDriver +; ... XStream dumper = new XStream(new JsonHierarchicalStreamDriver()); System.out.println(dumper.toXML(data));

Not ideal, but better than nothing...

Replies are listed 'Best First'.
Re^2: From Perl to Java
by amarquis (Curate) on Jul 25, 2008 at 13:07 UTC

    I was hoping somebody would drop in with something like this. I knew my usual method of "Just make every object have a debug_print method that knows how to print itself in a sane way" was not ideal, but hadn't done more than a cursory search for something better. Thanks!