I have just uploaded Mojo-JSONXS-0.001-TRIAL.tar.gz to PAUSE and it should
appear on CPAN sites soon.
If nobody screams, I'll release a non-trial version in a couple of days.
(This has been on my TODO list anyway, but sri's message prompted me to
cut-n-paste and get it done finally).
Jeremy
On Tuesday, November 25, 2014 7:32:34 AM UTC-8, sri wrote:
>
> There's a lot of modules for this already on CPAN, sadly most of them are
> terrible, it would be great if someone released one that actually worked
> most of the time.
>
> package Mojo::JSONXS;
>
> use Cpanel::JSON::XS;
> use Mojo::JSON;
> use Mojo::Util 'monkey_patch';
>
> my $BINARY =
> Cpanel::JSON::XS->new->utf8(1)->allow_nonref(1)->allow_blessed(1)
> ->convert_blessed(1);
> my $TEXT =
> Cpanel::JSON::XS->new->utf8(0)->allow_nonref(1)->allow_blessed(1)
> ->convert_blessed(1);
>
> monkey_patch 'Mojo::JSON', 'encode_json', sub { $BINARY->encode(shift)
> };
> monkey_patch 'Mojo::JSON', 'decode_json', sub { $BINARY->decode(shift)
> };
>
> monkey_patch 'Mojo::JSON', 'to_json', sub { $TEXT->encode(shift) };
> monkey_patch 'Mojo::JSON', 'from_json', sub { $TEXT->decode(shift) };
>
> monkey_patch 'Mojo::JSON', 'true', sub { Cpanel::JSON::XS::true() };
> monkey_patch 'Mojo::JSON', 'false', sub { Cpanel::JSON::XS::false() };
>
> 1;
>
> It's not even very hard, this one for example should cover pretty much all
> use cases.
>
> perl -MMojo::JSONXS -Mojo -E 'say
> app->build_controller->render_to_string(json => {foo => "/bar/baz", yada =>
> Mojo::JSON->true})'
>
> --
> sebastian
>
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.