protected function flush()
{
// The root node always exists
if (!isset($this->json['/'])) {
$this->json['/'] = null;
}
// Always save in reverse order
krsort($this->json);
// Comply to schema
$json = (object) $this->json;
if (isset($json->{'_order'})) {
$order = $json->{'_order'};
foreach ($order as $path => $entries) {
foreach ($entries as $key => $entry) {
$order[$path][$key] = (object) $entry;
}
}
$json->{'_order'} = (object) $order;
}
$this->encoder->encodeFile($json, $this->path, $this->schemaPath);
}