delete last coma if deleting last element before end of file
parent
1682d7d454
commit
5b29b7c8e3
|
@ -430,6 +430,11 @@ class JsonManipulator
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//check if we do not left a coma alone on previous line if it was the last line
|
||||||
|
if(preg_match('#,\s*$#', $matches['start']) && preg_match('#^\}$#', $matches['end'])) {
|
||||||
|
$matches['start'] = rtrim(preg_replace('#,(\s*)$#', '$1', $matches['start']), $this->indent);
|
||||||
|
}
|
||||||
|
|
||||||
$this->contents = $matches['start'] . $matches['end'];
|
$this->contents = $matches['start'] . $matches['end'];
|
||||||
if (preg_match('#^\{\s*\}\s*$#', $this->contents)) {
|
if (preg_match('#^\{\s*\}\s*$#', $this->contents)) {
|
||||||
$this->contents = "{\n}";
|
$this->contents = "{\n}";
|
||||||
|
|
Loading…
Reference in New Issue