From 0750f30254f1f0f76194b098cc92ec75f96f838a Mon Sep 17 00:00:00 2001 From: Josh Crawford Date: Thu, 3 Mar 2016 09:38:27 +1100 Subject: [PATCH] fix for json parsing when special characters in feed content --- feedme/services/FeedMe_FeedJSONService.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/feedme/services/FeedMe_FeedJSONService.php b/feedme/services/FeedMe_FeedJSONService.php index c2b4ed21..ecd683f0 100644 --- a/feedme/services/FeedMe_FeedJSONService.php +++ b/feedme/services/FeedMe_FeedJSONService.php @@ -12,8 +12,12 @@ public function getFeed($url, $primaryElement) { return false; } + // Perform cleanup on raw data first + $raw_content = preg_replace("/[\r\n]+/", " ", $raw_content); + $json = utf8_encode($raw_content); + // Parse the JSON string - $json_array = json_decode($raw_content, true); + $json_array = json_decode($json, true); // Look for and return only the items for primary element $json_array = craft()->feedMe_feed->findPrimaryElement($primaryElement, $json_array);