Fixes for JSON reader and writer

JSONReader: read end of objects in iterations
JSONWriter: only write iteration if it contains data