aboutsummaryrefslogtreecommitdiffstats
path: root/lib/WWW/FairViewer/ParseJSON.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/WWW/FairViewer/ParseJSON.pm')
-rw-r--r--lib/WWW/FairViewer/ParseJSON.pm12
1 files changed, 12 insertions, 0 deletions
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) = @_;