Fix serialization of array with empty object into JSON

Do not replace empty root with `ArrayObject` in `JsonSerializationVisitor::endVisitingObject()` when serialization was started as `array`.

Related issues:  #323, #277, #267, #242