Skip Menu |

This queue is for tickets about the Log-QnD CPAN distribution.

Report information
The Basics
Id: 100438
Status: open
Priority: 0/
Queue: Log-QnD

People
Owner: Nobody in particular
Requestors: ether [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: remove use of convert_blessed_universally
Found while doing http://grep.cpan.me/?q=convert_blessed_universally after reading https://rt.cpan.org/Ticket/Display.html?id=100423 (even better would be to switch to JSON::MaybeXS, to avoid having to use JSON::XS...)
On Tue Nov 18 15:13:41 2014, ETHER wrote: Show quoted text
> Found while doing http://grep.cpan.me/?q=convert_blessed_universally > after reading https://rt.cpan.org/Ticket/Display.html?id=100423 > > (even better would be to switch to JSON::MaybeXS, to avoid having to > use JSON::XS...)
I'd get rid of -convert_blessed_universally but so far I haven't been able to figure out how to get JSON or any other JSON serializer to work with blessed objects. To reduce the problem to minimal code, consider the following example which uses a blessed hash (CGI which is built-in). The first example, using -convert_blessed_universally, serializes the object to a JSON hash structure: #!/usr/bin/perl -w use strict; use CGI; use JSON qw{to_json -convert_blessed_universally}; my $cgi = CGI->new(); print to_json($cgi, {convert_blessed=>1}), "\n"; This next example, without -convert_blessed_universally, just returns null. The code is adapted straight from the JSON docs: #!/usr/bin/perl -w use strict; use CGI; use JSON; my $cgi = CGI->new(); print JSON->new->allow_blessed->convert_blessed->encode( $cgi ), "\n"; I've tried other JSON modules but basically run into the same problem: they won't just serialize a blessed hash or array. I don't want to add a TO_JSON method in Log::QnD because it doesn't really address the problem if nested structures are in the QnD object. So, I'll gladly make the change if someone can provide the code. I'll be happy to use JSON or another JSON serializer. -Miko