We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Here is the code:
use JSON::PP; use Data::Printer filters => { 'JSON::PP::Boolean' => sub { $_[0] ? 1 : 0 } } ; my $data = decode_json '{ "a":true, "b":false, "c":true }'; p $data;
it outputs:
\ { a 1, b 0, c var{a} }
How can I make it to output
\ { a 1, b 0, c 1 }
?
PS this question was inspired by https://www.jwz.org/blog/2016/10/death-to-jsonppboolean/ (and a tweet https://twitter.com/jwz/status/792831646525378560 )
The text was updated successfully, but these errors were encountered:
This can be achieved with more-or-less public interface using external filters:
package Data::Printer::Filter::JPB; use Data::Printer::Filter; filter 'JSON::PP::Boolean', sub { $_[0] ? 1 : 0 }, {show_repeated => 1};
use JSON::PP; use Data::Printer filters => { -external => [ 'JPB' ], }; my $data = decode_json '{ "a":true, "b":false, "c":true }'; p $data;
For inline filters, there's no easy way except for hacking into internal options:
p($data, _seen_override => {'JSON::PP::Boolean' => 1} );
Sorry, something went wrong.
@dur-randir thank you! This is exactly what i was looking for.
No branches or pull requests
Here is the code:
it outputs:
How can I make it to output
?
PS this question was inspired by https://www.jwz.org/blog/2016/10/death-to-jsonppboolean/ (and a tweet https://twitter.com/jwz/status/792831646525378560 )
The text was updated successfully, but these errors were encountered: