Add support for manipulating empty json files
parent
af6ef235e1
commit
534bd64cd1
|
@ -34,6 +34,9 @@ class JsonManipulator
|
||||||
}
|
}
|
||||||
|
|
||||||
$contents = trim($contents);
|
$contents = trim($contents);
|
||||||
|
if ($contents === '') {
|
||||||
|
$contents = '{}';
|
||||||
|
}
|
||||||
if (!$this->pregMatch('#^\{(.*)\}$#s', $contents)) {
|
if (!$this->pregMatch('#^\{(.*)\}$#s', $contents)) {
|
||||||
throw new \InvalidArgumentException('The json file must be an object ({})');
|
throw new \InvalidArgumentException('The json file must be an object ({})');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue