In Perl, checking a json decoded boolean value

后端 未结 1 818
借酒劲吻你
借酒劲吻你 2021-02-19 03:40

Decoded JSON booleans are objects:

#!/usr/bin/env perl

use strict;
use warnings;

use Data::Dumper;
use JSON;

my $json_string = \'{\"boolean_field\":true}\';
m         


        
相关标签:
1条回答
  • 2021-02-19 04:17

    It will be a truthy value in Perl. Just access it as normal.

    print 'true' if $decoded_json->{'boolean_field'};
    
    0 讨论(0)
提交回复
热议问题