data::dumper for ruby?

Discussion in 'Ruby' started by wroxdb, Nov 1, 2010.

  1. wroxdb

    wroxdb Guest

    how to dump a complicated data structure with ruby?

    I wrote:

    p data

    or:

    puts data.inspect

    They didn't work nice.

    Thanks.
     
    wroxdb, Nov 1, 2010
    #1
    1. Advertisements

  2. On 01.11.2010 06:54, wroxdb wrote:
    > how to dump a complicated data structure with ruby?


    I believe Marshal and Yaml are what you want.

    Kind regards

    robert

    --
    remember.guy do |as, often| as.you_can - without end
    http://blog.rubybestpractices.com/
     
    Robert Klemme, Nov 1, 2010
    #2
    1. Advertisements

  3. On Mon, Nov 1, 2010 at 6:54 AM, wroxdb <> wrote:
    > how to dump a complicated data structure with ruby?
    >
    > I wrote:
    >
    > p data
    >
    > or:
    >
    > puts data.inspect
    >
    > They didn't work nice.


    Alternatively to YAML, JSON (in Ruby 1.9: require "json";
    data.to_json) could work, too.

    --
    Phillip Gawlowski

    Though the folk I have met,
    (Ah, how soon!) they forget
    When I've moved on to some other place,
    There may be one or two,
    When I've played and passed through,
    Who'll remember my song or my face.
     
    Phillip Gawlowski, Nov 1, 2010
    #3
  4. Phillip Gawlowski wrote in post #958458:
    > On Mon, Nov 1, 2010 at 6:54 AM, wroxdb <> wrote:
    >> They didn't work nice.

    > Alternatively to YAML, JSON (in Ruby 1.9: require "json";
    > data.to_json) could work, too.


    There is also pp / prettyprint in the standard library.

    --
    Posted via http://www.ruby-forum.com/.
     
    Brian Candler, Nov 2, 2010
    #4
  5. Also awesome print is ... pretty awesome too :) =
    https://github.com/michaeldv/awesome_print#readme

    On Nov 2, 2010, at 9:26 PM, Brian Candler wrote:

    > Phillip Gawlowski wrote in post #958458:
    >> On Mon, Nov 1, 2010 at 6:54 AM, wroxdb <> wrote:
    >>> They didn't work nice.

    >> Alternatively to YAML, JSON (in Ruby 1.9: require "json";
    >> data.to_json) could work, too.

    >=20
    > There is also pp / prettyprint in the standard library.
    >=20
    > --=20
    > Posted via http://www.ruby-forum.com/.
    >=20
     
    Vicente Bosch Campos, Nov 10, 2010
    #5
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. kamal
    Replies:
    0
    Views:
    1,101
    kamal
    Aug 12, 2003
  2. Eric
    Replies:
    0
    Views:
    4,867
  3. rc
    Replies:
    3
    Views:
    2,080
    Chris Uppal
    Aug 16, 2004
  4. Sam

    Data::Dumper for Java?

    Sam, Nov 30, 2004, in forum: Java
    Replies:
    4
    Views:
    9,158
    Anonymous
    Feb 11, 2011
  5. Edward wijaya

    Data::Dumper for Python

    Edward wijaya, Oct 28, 2004, in forum: Python
    Replies:
    7
    Views:
    1,309
    A.M. Kuchling
    Oct 29, 2004
  6. Miguel Manso
    Replies:
    1
    Views:
    746
    Wallace Owen
    Jun 15, 2006
  7. Josef Wolf

    Data::Dumper for Ruby?

    Josef Wolf, Sep 3, 2009, in forum: Ruby
    Replies:
    8
    Views:
    318
    Mark Thomas
    Sep 4, 2009
  8. Replies:
    4
    Views:
    465
    Paul Lalli
    Aug 1, 2007
Loading...