in reply to Re: YAML::Syck serializing Dump into single line
in thread YAML::Syck serializing Dump into single line

What cLive ;-) probably meant was for some option to make the YAML::Syck dumper spit inline sequences and maps, as in

{ a : [ 1, 2, 3], b : { b_a: "a\n" } }
instead of the usual multi-line representation (which uses a lot of indentation indeed).
--- a: - 1 - 2 - 3 b: b_a: "a\n"

I am not sure of what exactly syck can do, but it is very possible that even if there's such option in the underlying library, it is not currently exposed by the binding code implemented by YAML::Syck. The module is very immature yet, but fast as hell (for things it can grok).

Replies are listed 'Best First'.
Re^3: YAML::Syck serializing Dump into single line
by Fletch (Bishop) on Jan 25, 2007 at 15:53 UTC

    Perhaps JSON::Syck (which uses libsyck to spit out more JSON-friendly YAML) may be more what he's looking for.

    $ perl -MJSON::Syck=Dump -le 'print JSON::Syck::Dump( { a => { b => "c +", d => [qw/1 2 3/] } } )' {"a":{"b":"c","d":["1","2","3"]}}
Re^3: YAML::Syck serializing Dump into single line
by cLive ;-) (Prior) on Jan 25, 2007 at 17:02 UTC

    "The module is very immature yet, but fast as hell (for things it can grok)."

    Indeed! I benchmarked it against reading/writing a hashref of arrayref of hashrefs against XML::Simple, and it created files three times faster, and parsed them nine times faster. Unfortunately, the context I'm currently working in involves one line of data transfer only, so I need to work around the new lines if I'm going to work on integrating it.

    I think I'll have to examine the JSON::Syck implementation when I finally get round to trying to implement this. I like YAML because, unlike XML, it actually makes sense to me :)