diff --git a/src/GettextPOGenerator.php b/src/GettextPOGenerator.php index 33c36af..489b7b7 100644 --- a/src/GettextPOGenerator.php +++ b/src/GettextPOGenerator.php @@ -164,7 +164,10 @@ private function addStringsFromJsonFiles($translations) { // Load each JSON file to get source strings foreach ($this->JsonFiles() as $jsonFile) { - $jsonTranslations = json_decode(file_get_contents($jsonFile), true); + $jsonTranslations = json_decode(file_get_contents($jsonFile), true); + if (!is_array($jsonTranslations)) { + throw new \Exception("The file '$jsonFile' is not valid JSON.'"); + } foreach ($jsonTranslations as $key => $value) { $sourceStrings[] = $key;