in reply to Json::PP data error
What's in $today? It seems to be an object of some sort, not a string, which may explain why putting the double-quotes around it allows it to be processed.
This works:
use warnings; use strict; use Data::Dumper; use JSON; my $today = '2019-12-23'; my @array = ($today); my $j = encode_json \@array; my $p = decode_json $j; print Dumper $p;
But changing the $today assignment to:
my $today = DateTime->now;
...results in:
encountered object '2019-12-23T22:45:49', but neither allow_blessed, c +onvert_blessed nor allow_tags settings are enabled (or TO_JSON/FREEZE + method missing) at date.pl line 12.
Do a print ref $today; within the "working" version of the script to understand what type of object $today is, and we'll help you figure out if there's a more proper way to stringify the object.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Json::PP data error
by IB2017 (Pilgrim) on Dec 23, 2019 at 22:58 UTC | |
by davido (Cardinal) on Dec 24, 2019 at 04:48 UTC |