in reply to Re: Escape $ in JSON::XS decoded
in thread Escape $ in JSON::XS decoded

My apologies, I didn't catch that, but it explains part of the problem.

In the actual JSON file, it reads as follows:

"updated":{ "$t":"2019-07-19T20:04:56.046Z"

But when Perl and or JSON::XS is loading the JSON file, it seems to be reinterpreting the $t some how as the current time. I have not declared $t at all.

I knew what the answer was supposed to be in my head, and my brain just didn't connect that the DataDummper was putting the current time, as I was looking at the raw JSON.

This just baffles me even more. I'll keep digging.

Replies are listed 'Best First'.
Re^3: Escape $ in JSON::XS decoded
by choroba (Cardinal) on Oct 16, 2020 at 21:03 UTC
    I can't reproduce that either. It still returns the value stored in the original JSON, as expected.
    #!/usr/bin/perl use strict; use warnings; use JSON::XS; my $json = '{"feed":{"updated":{"$t":"2019-07-19T20:04:56.046Z"}}}'; my $decoded_json = decode_json($json); print $decoded_json->{feed}->{updated}->{'$t'}; # 2019-07-19T20:04:56 +.046Z
    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Re^3: Escape $ in JSON::XS decoded
by haukex (Archbishop) on Oct 16, 2020 at 21:03 UTC
    But when Perl and or JSON::XS is loading the JSON file, it seems to be reinterpreting the $t some how as the current time.

    Sorry, but almost certainly not.

    use warnings; use strict; use Data::Dump; use JSON::XS; dd decode_json('{ "updated":{ "$t":"2019-07-19T20:04:56.046Z" } }') __END__ { updated => { "\$t" => "2019-07-19T20:04:56.046Z" } }

    Again, please provide a Short, Self-Contained, Correct Example that we can run that shows otherwise.