1
0
Fork 0

Handle false and empty decoded json values as valid

pull/48/head
Jordi Boggiano 2011-10-02 20:49:26 +02:00
parent 18e28a2a9f
commit 9210500714
1 changed files with 4 additions and 3 deletions

View File

@ -89,8 +89,9 @@ class JsonFile
*/
public static function parseJson($json)
{
$hash = json_decode($json, true);
if (!$hash) {
$data = json_decode($json, true);
if (false === $data && 'false' !== $json) {
switch (json_last_error()) {
case JSON_ERROR_NONE:
$msg = 'No error has occurred, is your composer.json file empty?';
@ -114,6 +115,6 @@ class JsonFile
throw new \UnexpectedValueException('Incorrect composer.json file: '.$msg);
}
return $hash;
return $data;
}
}