Skip Menu |

This queue is for tickets about the JE CPAN distribution.

Report information
The Basics
Id: 75369
Status: resolved
Priority: 0/
Queue: JE

People
Owner: Nobody in particular
Requestors: perl [...] toby.ink
Cc:
AdminCc:

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



Subject: JE could play nicer with JSON
Dumping the result of an eval using JSON.pm's to_json method croaks. This is because rather than returning normal Perl hashes/arrays, eval returns blessed objects. If those blessed objects provided a TO_JSON method, then JSON.pm would use that when dumping. This works: *JE::Boolean::TO_JSON = *JE::Null::TO_JSON = *JE::Number::TO_JSON = *JE::Object::TO_JSON = *JE::String::TO_JSON = *JE::Undefined::TO_JSON = sub { (shift)->value };
On Tue Feb 28 05:38:58 2012, TOBYINK wrote: Show quoted text
> Dumping the result of an eval using JSON.pm's to_json method croaks. This > is because rather than returning normal Perl hashes/arrays, eval returns > blessed objects. > > If those blessed objects provided a TO_JSON method, then JSON.pm would > use that when dumping. This works: > > *JE::Boolean::TO_JSON = > *JE::Null::TO_JSON = > *JE::Number::TO_JSON = > *JE::Object::TO_JSON = > *JE::String::TO_JSON = > *JE::Undefined::TO_JSON = > sub { (shift)->value };
Thank you for the suggestion. I’ve put this in version 0.059.