write json stream, write lines too
438642
def lines2file(lines, filename, encoding='utf-8'):
    
    with codecs.open(filename, "w", encoding=encoding) as f:
        for line in lines:
            f.write(line)
            f.write("\n")
379245
public synchronized void writeJSON(String outputDirectory, boolean bForceWrite) {
        logger.entering(new Object[] { outputDirectory, bForceWrite });

        long currentTime = System.currentTimeMillis();
        if (!bForceWrite && (currentTime - previousTime < ONE_MINUTE)) {
            return;
        }
        previousTime = currentTime;

        parseCompletedTest();

        generateReports(outputDirectory);

        logger.exiting();
    }
476792
private static final void writeJson(Writer os, //
                                        Object object, //
                                        SerializeConfig config, //
                                        SerializeFilter[] filters, //
                                        DateFormat dateFormat, //
                                        int defaultFeatures, //
                                        SerializerFeature... features) {
        SerializeWriter writer = new SerializeWriter(os, defaultFeatures, features);

        try {
            JSONSerializer serializer = new JSONSerializer(writer, config);

            if (dateFormat != null) {
                serializer.setDateFormat(dateFormat);
                serializer.config(SerializerFeature.WriteDateUseDateFormat, true);
            }

            if (filters != null) {
                for (SerializeFilter filter : filters) {
                    serializer.addFilter(filter);
                }
            }
            serializer.write(object);
        } finally {
            writer.close();
        }
    }
1040764
def write(self, path):
        """"""
        with open(path, 'w') as fd:
            fd.write(json.dumps(
                {
                    "created_at": self._created_at,
                    "version": self._version,
                    "mtllibs": self._mtllibs,
                    "vertex_buffers": self._vertex_buffers,
                },
                indent=2,
            ))
151676
def write_json(dictionary, filename):
    """"""
    with open(filename, 'w') as data_file:
        json.dump(dictionary, data_file, indent=4, sort_keys=True)
    print('--> Wrote ' + os.path.basename(filename))
990588
public <T> void write(final OutputStream stream, final T object,
			final DataTypeDescriptor<T> descriptor, final boolean indent) {
		try {
			jsonFormat.write(stream, object, descriptor, indent);
		} catch (Exception e) {
			throw propagate(e);
		}
	}
1332526
@Override
  public void write(JsonWriter out, MarkTiming markTiming) throws IOException {
    out.beginArray();

    out.value(markTiming.getMark());
    out.value(markTiming.getTime());

    out.endArray();
    out.flush();
  }
571307
def WriteRow(stream, values):
  ""
  stream.write(','.join([EncodeForCSV(val) for val in values]))
  stream.write('\n')
899236
def writeline(self, data, crlf="\n"):  # pylint: disable=arguments-differ
        
        GenericProcess.writeline(self, data, crlf=crlf)
403986
def _write_dict(self, val, outstream):
        '''
        
        '''
        fields = val.keys()
        length = len(fields)
        self.write_dict_start(length, outstream)
        if length > 0:
            self.write_dict_field(fields[0], val[fields[0]], outstream)
            idx = 1
            while idx < length:
                name = fields[idx]
                value = val[fields[idx]]
                self.write_dict_field_separator(name, value, outstream)
                self.write_dict_field(name, value, outstream)
                idx += 1
        self.write_dict_end(length, outstream)
56513
def write_batch_json(self, content):
        """"""
        timestamp = str(time.time()).replace('.', '')
        batch_json_file = os.path.join(
            self.tcex.args.tc_temp_path, 'batch-{}.json'.format(timestamp)
        )
        with open(batch_json_file, 'w') as fh:
            json.dump(content, fh, indent=2)
205739
def write_json_to_file(self, net_type, filename, indent='no-indent'):
    '''
    
    '''
    export_data.write_json_to_file(self, net_type, filename, indent)
16973
@SuppressWarnings({ "rawtypes", "unchecked" })
    private void writeJSON(Object value) throws JSONException {
        if (JSONObject.NULL.equals(value)) {
            write(zipNull, 3);
        } else if (Boolean.FALSE.equals(value)) {
            write(zipFalse, 3);
        } else if (Boolean.TRUE.equals(value)) {
            write(zipTrue, 3);
        } else {
            if (value instanceof Map) {
                value = new JSONObject((Map) value);
            } else if (value instanceof Collection) {
                value = new JSONArray((Collection) value);
            } else if (value.getClass().isArray()) {
                value = new JSONArray(value);
            }
            if (value instanceof JSONObject) {
                write((JSONObject) value);
            } else if (value instanceof JSONArray) {
                write((JSONArray) value);
            } else {
                throw new JSONException("Unrecognized object");
            }
        }
    }
890989
def write_json(obj, path):
    """"""
    obj_str = text_type(json.dumps(obj, indent=4, separators=(",", ": "),
                                   ensure_ascii=False))

    helpers.ensure_dir_exists(os.path.dirname(path))

    with io.open(path, "w", encoding='utf-8') as target:
        target.write(obj_str)
1027284
def write_as_json(blob, dest, indent=0, sort_keys=True):
    
    opened_out = False
    if is_str_type(dest):
        out = codecs.open(dest, mode='w', encoding='utf-8')
        opened_out = True
    else:
        out = dest
    try:
        json.dump(blob, out, indent=indent, sort_keys=sort_keys)
        out.write('\n')
    finally:
        out.flush()
        if opened_out:
            out.close()
607618
private void writeJsonForJobs(PrintWriter wrt, List<RecentJobEvent> jobs) {
		
		try {
		
			wrt.write("[");
			
			// Loop Jobs
			for (int i = 0; i < jobs.size(); i++) {
				RecentJobEvent jobEvent = jobs.get(i);
	
				writeJsonForJob(wrt, jobEvent);
	
				//Write seperator between json objects
				if(i != jobs.size() - 1) {
					wrt.write(",");
				}
			}
			wrt.write("]");
		
		} catch (EofException eof) { // Connection closed by client
			LOG.info("Info server for jobmanager: Connection closed by client, EofException");
		} catch (IOException ioe) { // Connection closed by client	
			LOG.info("Info server for jobmanager: Connection closed by client, IOException");
		} 
		
	}
756929
public void writeJSON(JSONValue jc, JSONWriter jb, boolean writeClass)
            throws IOException {
        jb.arrayBegin();
        for (Object item : mArray) {
            if (item == null)
                jb.valueNull();
            else
                jc.writeValue(item, jb, writeClass);
        }
        jb.arrayEnd();
    }