diff --git a/dist.ini b/dist.ini index 5f873cfcb..d98c73a69 100644 --- a/dist.ini +++ b/dist.ini @@ -37,9 +37,6 @@ Convert::Braille = 0.05 Math::Round = 0.06 Convert::Morse = 0.05 Net::IDN::Encode = 2.003 -; IsValid::JSON -Try::Tiny = 0 -JSON = 0 Astro::MoonPhase = 0 Acme::rafl::Everywhere = 0.008 Lingua::EN::Numbers::Ordinate = 1.02 diff --git a/lib/DDG/Goodie/IsValid/JSON.pm b/lib/DDG/Goodie/IsValid/JSON.pm deleted file mode 100644 index 4c7e67160..000000000 --- a/lib/DDG/Goodie/IsValid/JSON.pm +++ /dev/null @@ -1,46 +0,0 @@ -package DDG::Goodie::IsValid::JSON; -# ABSTRACT: Check whether the submitted data is valid JSON. - -use DDG::Goodie; - -use Try::Tiny; -use JSON qw(from_json); - -primary_example_queries 'is valid {"test": "json"}'; -secondary_example_queries 'valid? ["test", "json"]'; -description 'validate JSON data'; -name 'IsValid::JSON'; -code_url 'https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/IsValid/JSON.pm'; -category 'programming'; -topics 'programming'; - -attribution github => ['https://github.com/ghedo', 'ghedo' ], - web => ['http://ghedini.me', 'Alessandro Ghedini']; - -zci answer_type => 'isvalid'; -zci is_cached => 1; - -triggers any => 'json'; - -handle remainder => sub { - return unless s/ ?(is )?valid\?? ?//gi; - - my ($result, $error) = try { - from_json $_; - return 'valid!'; - } catch { - $_ =~ /^(.* at character offset \d+ .*) at/; - return ('invalid: ', $1); - }; - - my $answer = "Your JSON is $result"; - my $answer_html = $answer; - - $answer .= $error if $error; - $answer_html .= "
$error
" if $error; - - return $answer, html => $answer_html -}; - -1; diff --git a/t/IsValid.t b/t/IsValid.t deleted file mode 100644 index cc02af927..000000000 --- a/t/IsValid.t +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env perl - -use strict; -use warnings; - -use Test::More; -use DDG::Test::Goodie; - -zci answer_type => 'isvalid'; -zci is_cached => 1; - -ddg_goodie_test( - [qw(DDG::Goodie::IsValid::JSON)], - 'is valid json {"test":"lol"}' => test_zci( - 'Your JSON is valid!', - html => 'Your JSON is valid!' - ), - 'is valid json {"test" "lol"}' => test_zci( - 'Your JSON is invalid: \':\' expected, at character offset 8 (before ""lol"}")', - html => 'Your JSON is invalid:
\':\' expected, at character offset 8 (before ""lol"}")
' - ) -); - -done_testing;