Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > data::dumper for ruby?

Reply
Thread Tools

data::dumper for ruby?

 
 
wroxdb
Guest
Posts: n/a
 
      11-01-2010
how to dump a complicated data structure with ruby?

I wrote:

p data

or:

puts data.inspect

They didn't work nice.

Thanks.

 
Reply With Quote
 
 
 
 
Robert Klemme
Guest
Posts: n/a
 
      11-01-2010
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/
 
Reply With Quote
 
 
 
 
Phillip Gawlowski
Guest
Posts: n/a
 
      11-01-2010
On Mon, Nov 1, 2010 at 6:54 AM, wroxdb <(E-Mail Removed)> 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.

 
Reply With Quote
 
Brian Candler
Guest
Posts: n/a
 
      11-02-2010
Phillip Gawlowski wrote in post #958458:
> On Mon, Nov 1, 2010 at 6:54 AM, wroxdb <(E-Mail Removed)> 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/.

 
Reply With Quote
 
Vicente Bosch Campos
Guest
Posts: n/a
 
      11-10-2010

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 <(E-Mail Removed)> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments