From c951f7aa94593aa32ac98da0648f139d93098956 Mon Sep 17 00:00:00 2001
From: rachellawson <rachellawson@66273.no-reply.drupal.org>
Date: Wed, 30 Nov 2016 17:07:39 -0600
Subject: [PATCH] =?UTF-8?q?Issue=20#2799353=20by=20rachel=5Fnorfolk:=20jso?=
 =?UTF-8?q?n=5Fdecode()=20assumes=20utf8=20content=20-=20let=E2=80=99s=20m?=
 =?UTF-8?q?ake=20sure=20it=20gets=20it?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/Plugin/migrate_plus/data_parser/Json.php | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/Plugin/migrate_plus/data_parser/Json.php b/src/Plugin/migrate_plus/data_parser/Json.php
index 723da8c2..68dba2f8 100755
--- a/src/Plugin/migrate_plus/data_parser/Json.php
+++ b/src/Plugin/migrate_plus/data_parser/Json.php
@@ -42,8 +42,17 @@ class Json extends DataParserPluginBase implements ContainerFactoryPluginInterfa
    */
   protected function getSourceData($url) {
     $response = $this->getDataFetcherPlugin()->getResponseContent($url);
+
     // Convert objects to associative arrays.
     $source_data = json_decode($response, TRUE);
+
+    // If json_decode() has returned NULL, it might be that the data isn't
+    // valid utf8 - see http://php.net/manual/en/function.json-decode.php#86997.
+    if (is_null($source_data)) {
+      $utf8response = utf8_encode($response);
+      $source_data = json_decode($utf8response);
+    }
+
     // Backwards-compatibility for depth selection.
     if (is_int($this->itemSelector)) {
       return $this->selectByDepth($source_data);
-- 
GitLab