Move writing of objects and arrays to JsonWriter

With the new Members iterator on JsonObject, JsonWriter can write
objects itself without losing performance. Move the code to write
JSON objects and arrays to the JsonWriter, where it belongs.