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. Advertising

  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. Advertising

  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. Advertising

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,006
    kamal
    Aug 12, 2003
  2. Eric
    Replies:
    0
    Views:
    4,523
  3. rc
    Replies:
    3
    Views:
    1,906
    Chris Uppal
    Aug 16, 2004
  4. Josef Wolf

    Data::Dumper for Ruby?

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

Share This Page