Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languageperl
linenumberstrue
use LoxBerry::JSON;
my $jsonparser = Stats4Lox::JSON->new();
$jsonparser->open(filename => "/tmp/somefile.json");

my $jsonstr = $jsonparser->encode();
my $jsonstr_pretty = $jsonparser->encode( pretty => 1 );

Try the living example in our testing folder: /opt/loxberry/libs/perllib/LoxBerry/testing/json_encode.pl

jsblock: Generate a ready string to insert into your <script> block (available from LoxBerry 1.4.3)

...

Code Block
languagejs
linenumberstrue
<script>
config = JSON.parse('{"SMTP":{"EMAIL":"my@mail.com"}}');
console.log(config.SMTP.EMAIL);
</script>

Try the living example in our testing folder: /opt/loxberry/libs/perllib/LoxBerry/testing/json_jsblock.cgi