The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

JavaScript::Dumper - Dump JavaScript data structures from Perl objects. Allows unquoted strings and numbers.

SYNOPSIS

 use JavaScript::Dumper;

 my $js = js_dumper([{foo => "bar", call => \"function"}]);
 
 # results in:
 # $js = "[{"foo": "bar", "call": function}]"; 

DESCRIPTION

This module uses JSON::PP as base and overrides valueToJson to accept SCALAR-refs to be returned without quotes.

FUNCTIONS

js_dumper

Dumps any perl data structure.

\'1' becomes "true" \'0' becomes "false"

See JSON::PP or JSON::XS for more details.

METHODS

new

Returns JavaScript::Dumper object.

others

For all other methods see JSON::PP and JSON::XS.

CAVEATS

JavaScript::Dumper is as slow as JSON::PP. You might want to cache the output or use it only for small objects.

TODO

JavaScript::Dumper::XS

Find someone who does a speedy version of this module

SEE ALSO

JSON::PP, JSON::XS

AUTHOR

Moritz Onken (perler)

COPYRIGHT AND LICENSE

Copyright 2007 by Moritz Onken

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.