in reply to Re: Why is Dumper showing decoded JSON booleans like this?
in thread Why is Dumper showing decoded JSON booleans like this?

Okay. That makes sense. I guess my problem then becomes something different which is when using PHP::Serialization to serialize the decoded json text:
#!/usr/bin/perl -w use strict; use Data::Dumper; use JSON; use PHP::Serialization qw(serialize unserialize); my $json_text ='{ "boolean": true }'; my $json_text_decoded = decode_json $json_text; serialize($json_text_decoded);

OUTPUT:

Not a HASH reference at lib/PHP/Serialization.pm line 454.

It dies when working on the object data type. Is there a straightforward way to convert the boolean object to a literal string?

Replies are listed 'Best First'.
Re^3: Why is Dumper showing decoded JSON booleans like this?
by ikegami (Patriarch) on Mar 03, 2010 at 20:18 UTC

    You'll have to traverse the returned data structure, using JSON::is_bool to check for boolean nodes, replacing boolean nodes with the values of your choice.

    If PHP::Serialization supported custom object serializers, you could just write one of those for JSON::PP::Boolean, but it doesn't appear to be the case.

      Thank you for your guidance. This is exactly the help I needed.