From 739c821a54c01816e60eb5f774c8977a1e221ea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs?= Date: Fri, 9 Jul 2021 15:27:16 -0500 Subject: upstream --- lib/WWW/FairViewer/ParseJSON.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/WWW/FairViewer/ParseJSON.pm') diff --git a/lib/WWW/FairViewer/ParseJSON.pm b/lib/WWW/FairViewer/ParseJSON.pm index 4945a2a..6733eb0 100644 --- a/lib/WWW/FairViewer/ParseJSON.pm +++ b/lib/WWW/FairViewer/ParseJSON.pm @@ -23,6 +23,18 @@ Parse a JSON string and return a HASH ref. =cut +sub parse_utf8_json_string { + my ($self, $json) = @_; + + if (not defined($json) or $json eq '') { + return {}; + } + + require JSON; + my $hash = eval { JSON::from_json($json) }; + return $@ ? do { warn "[JSON]: $@\n"; {} } : $hash; +} + sub parse_json_string { my ($self, $json) = @_; -- cgit v1.2.3