private Writer write(Writer writer)
            throws JSONException {
        try {
            boolean commanate = false;
            final int length = this.size();
            Iterator<String> keys = this.keys();
            writer.write('{');

            if (length == 1) {
                String key = keys.next();
                writer.write(quote(key));
                writer.write(':');
                writeValue(writer, this.map.get(key));
            } else if (length != 0) {
                while (keys.hasNext()) {
                    String key = keys.next();
                    if (commanate) {
                        writer.write(',');
                    }
                    writer.write(quote(key));
                    writer.write(':');
                    writeValue(writer, this.map.get(key));
                    commanate = true;
                }
            }
            writer.write('}');
            return writer;
        } catch (IOException exception) {
            throw new JSONException(exception);
        }
    }
@author Robert HG (254963746@qq.com) on 12/28/15.
lts-core/src/main/java/com/github/ltsopensource/json/JSONObject.java