Skip to content

Commit

Permalink
Version to 0.28; examples tidied up
Browse files Browse the repository at this point in the history
  • Loading branch information
benkasminbullock committed Nov 23, 2020
1 parent b3caef1 commit ca96a03
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,4 +1,4 @@
0.27_01 2020-11-23
0.28 2020-11-24
* Test context-dependent variables & use numerical part only if valid.

0.27 2020-11-22
Expand Down
4 changes: 2 additions & 2 deletions examples/indent-format.pl
Expand Up @@ -2,8 +2,8 @@
use warnings;
use strict;
use JSON::Create;
my %thing = ("it's your thing" => [qw! do what you wanna do!],
"I can't tell you" => [qw! who to sock it to !]);
my %thing = ("it's your thing" => [qw! do what you !, {wanna => 'do'}],
"I can't tell you" => [{who => 2}, qw! sock it!, 2]);
my $jc = JSON::Create->new ();
$jc->indent (1);
my $out = $jc->run (\%thing);
Expand Down
4 changes: 2 additions & 2 deletions examples/indent.pl
Expand Up @@ -2,8 +2,8 @@
use warnings;
use strict;
use JSON::Create;
my %thing = ("it's your thing" => [qw! do what you wanna do!],
"I can't tell you" => [qw! who to sock it to !]);
my %thing = ("it's your thing" => [qw! do what you !, {wanna => 'do'}],
"I can't tell you" => [{who => 2}, qw! sock it!, 2]);
my $jc = JSON::Create->new ();
$jc->indent (1);
print $jc->run (\%thing);
4 changes: 2 additions & 2 deletions examples/type-handler-scalar.pl
Expand Up @@ -4,12 +4,12 @@
use JSON::Create;
my $jc = JSON::Create->new ();
$jc->strict (1);
print $jc->run (\1), "\n";
print "Before: ", $jc->run (\1), "\n";
$jc->type_handler (sub {
my ($thing) = @_;
if (ref $thing eq 'SCALAR') {
return $$thing;
}
});
print $jc->run (\1), "\n";
print "After: ", $jc->run (\1), "\n";

4 changes: 3 additions & 1 deletion examples/type-handler.pl
Expand Up @@ -4,6 +4,7 @@
use utf8;
use FindBin '$Bin';
use JSON::Create 'create_json';
binmode STDOUT, ":encoding(utf8)";
my %crazyhash = (
'code' => sub { return "강남스타일"; },
'regex' => qr/.*/,
Expand All @@ -12,6 +13,7 @@
my $jc = JSON::Create->new ();
# Let's validate the output of the subroutine below.
$jc->validate (1);
$jc->indent (1);
# Try this one weird old trick to convert your Perl type.
$jc->type_handler (
sub {
Expand All @@ -27,4 +29,4 @@
return create_json ({ type => $type, value => $value, });
}
);
print $jc->run (\%crazyhash);
print $jc->run (\%crazyhash), "\n";
2 changes: 1 addition & 1 deletion lib/JSON/Create.pm
Expand Up @@ -7,7 +7,7 @@ require Exporter;
);
use warnings;
use strict;
our $VERSION = '0.27_01';
our $VERSION = '0.28';

# Are we running as XS?

Expand Down
15 changes: 15 additions & 0 deletions lib/JSON/Create.pod.tmpl
Expand Up @@ -1063,6 +1063,21 @@ This is a backup module for JSON::Create in pure Perl.

=back

=head2 Blog posts

There are some blog posts about the JSON::Create internals of interest
to Perl XS programmers here:

=over

=item L<The mysterious case of the SVt_PVIV|http://blogs.perl.org/users/ben_bullock/2020/11/the-mysterious-case-of-the-svt-pviv.html>

=item L<JSON::Create now features indentation|http://blogs.perl.org/users/ben_bullock/2020/11/jsoncreate-now-features-indentation.html>

=item L<av_fetch can return NULL|http://blogs.perl.org/users/ben_bullock/2020/02/av-fetch-can-return-null.html>

=back

[% INCLUDE "author" %]

=cut
Expand Down
2 changes: 1 addition & 1 deletion lib/JSON/Create/PP.pm
Expand Up @@ -56,7 +56,7 @@ use Carp qw/croak carp confess cluck/;
use Scalar::Util qw/looks_like_number blessed reftype/;
use Unicode::UTF8 qw/decode_utf8 valid_utf8/;
use B;
our $VERSION = '0.27_01';
our $VERSION = '0.28';

# http://stackoverflow.com/questions/1185822/how-do-i-create-or-test-for-nan-or-infinity-in-perl#1185828

Expand Down

0 comments on commit ca96a03

Please sign in to comment.