Data::Dump::JavaScript - Pretty printing of data structures as JavaScript
version 0.002
use Data::Dump::JavaScript qw( dump_javascript true false ); my $javascript = dump_javascript({ foo => [1, 2], bar => 'hello!', baz => true });
Data::Dump::JavaScript is a fork of JSON::Tiny version 0.55 which outputs pretty-printed JavaScript.
The indention is according to JavaScript Standard Style and JavaScript Semi-Standard Style. Hash keys are sorted in standard string comparison order.
Data::Dump::JavaScript implements the following functions, which can be imported individually.
my $false = false;
False value, used because Perl has no equivalent.
my $true = true;
True value, used because Perl has no native equivalent.
my $bytes = dump_javascript({ foo => 'bar' });
Encode Perl value to UTF-8 encoded JavaScript.
Can only dump Perl structures as JavaScript variable assignment. No boolean handling, no formatting.
No boolean handling, no formatting.
Alexander Hartmaier <abraxxa@cpan.org>
This software is copyright (c) 2020 by Alexander Hartmaier.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Data::Dump::JavaScript, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Dump::JavaScript
CPAN shell
perl -MCPAN -e shell install Data::Dump::JavaScript
For more information on module installation, please visit the detailed CPAN module installation guide.