YAML::Tiny::LikeJSON - Use YAML::Tiny like JSON
use YAML::Tiny::LikeJSON; my $yaml = YAML::Tiny::LikeJSON->new; my $data = $yaml->decode( <<_END_ ); apple: 1 banana: - 1 - 2 - 3 _END_ print $yaml->encode( $data ); # Prints out the following: (without the '---' document separator) # apple: 1 # banana: # - 1 # - 2 # - 3 _END_
YAML::Tiny::LikeJSON provides a way to encode/decode YAML (Tiny) in a way similar to how JSON.pm works.
It will only deal with one YAML document at a time, so if you try to decode more than one document, it will ignore every document but the first (and issue a warning at the same time). For example:
YAML::Tiny::LikeJSON->decode( <<_END_ ); apple: 1 --- banana: 2 _END_ # The above will emit the following warning: Decoded more than 1 document (actually 2, but only returning the first)
Create a handle for invoking
Does not accept any arguments or options (for now)
Return a YAML encoded string representing $data
The returned string will not have the leading YAML document separator (---)
Return some Perl data representing $document
Will only return data from the first document. Data from following documents will be discarded (with a warning)
Robert Krimen <firstname.lastname@example.org>
This software is copyright (c) 2010 by Robert Krimen.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.