write JSON (object and array)