diff options
author | Eric Wong <e@80x24.org> | 2020-11-23 07:05:52 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2020-11-24 05:03:55 +0000 |
commit | f1bdfad51c98825e7e2569aa34db7d3879fa9ef4 (patch) | |
tree | 840f1431b84a7abdedf928ca0dfa1959baeeac0a /lib/PublicInbox/Config.pm | |
parent | 58e764d179131b0fba8590915e2528248be26329 (diff) | |
download | public-inbox-f1bdfad51c98825e7e2569aa34db7d3879fa9ef4.tar.gz |
We'll be using JSON in MiscIdx and MiscSearch, and PublicInbox::Config seems like an appropriate place to put it.
Diffstat (limited to 'lib/PublicInbox/Config.pm')
-rw-r--r-- | lib/PublicInbox/Config.pm | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm index d2010f7a..039eb445 100644 --- a/lib/PublicInbox/Config.pm +++ b/lib/PublicInbox/Config.pm @@ -488,4 +488,16 @@ sub urlmatch { } } +sub json { + state $json; + $json //= do { + for my $mod (qw(Cpanel::JSON::XS JSON::MaybeXS JSON JSON::PP)) { + eval "require $mod" or next; + # ->ascii encodes non-ASCII to "\uXXXX" + $json = $mod->new->ascii(1) and last; + } + $json; + }; +} + 1; |