Writes an object to a writer as a JSON string, does not close the writer.
436518
public <T> void write(final PrintWriter writer, final T object,
			final DataTypeDescriptor<T> descriptor, final boolean indent) {
		try {
			jsonFormat.write(writer, object, descriptor, indent);
		} catch (Exception e) {
			throw propagate(e);
		}
	}
1269222
protected void writeJSON(final HttpServletResponse resp, final Object obj)
      throws IOException {
    writeJSON(resp, obj, false);
  }
1064146
private void write(JSONObject jsonobject) throws JSONException {

// JSONzip has two encodings for objects: Empty Objects (zipEmptyObject) and
// non-empty objects (zipObject).

        boolean first = true;
        Iterator<String> keys = jsonobject.keys();
        while (keys.hasNext()) {
            if (probe) {
                log();
            }
            Object key = keys.next();
            if (key instanceof String) {
                if (first) {
                    first = false;
                    write(zipObject, 3);
                } else {
                    one();
                }
                writeName((String) key);
                Object value = jsonobject.get((String) key);
                if (value instanceof String) {
                    zero();
                    writeString((String) value);
                } else {
                    one();
                    writeValue(value);
                }
            }
        }
        if (first) {
            write(zipEmptyObject, 3);
        } else {
            zero();
        }
    }
567297
def write_object_to_file(self, obj, path='.', filename=None):
        """"""
        output = self.json_dumps(obj) + '\n'
        if filename is None:
            filename = self.safe_filename(obj['_type'], obj['_id'])
        filename = os.path.join(path, filename)
        self.pr_inf("Writing to file: " + filename)
        with open(filename, 'w') as f:
            f.write(output)
        # self.pr_dbg("Contents: " + output)
        return filename
961898
void writeTo(JsonGenerator generator) throws IOException {
        DeserializationState deserState = _deserState.get();

        if (deserState.isDeserialized()) {
            // Object has already been deserialized, use standard writer
            generator.writeObject(deserState.deserialized);
            return;
        }

        if (deserState.overrides.isEmpty()) {
            // With no overrides the most efficient action is to copy the original JSON verbatim.
            try {
                generator.writeRaw(deserState.json);
                return;
            } catch (UnsupportedOperationException e) {
                // Not all parsers are guaranteed to support this.  If this is one then use the default
                // generator implementation which follows.
            }
        }

        ObjectCodec codec = generator.getCodec();
        if (codec == null) {
            // No codec, defer to generator
            generator.writeObject(deserialized());
            return;
        }

        JsonParser parser = codec.getFactory().createParser(deserState.json);
        checkState(parser.nextToken() == JsonToken.START_OBJECT, "JSON did not contain an object");
        generator.writeStartObject();

        // Typically the JSON string has been pre-sorted.  Insert the overrides in order.  If it turns out the
        // JSON wasn't sorted then we'll just dump the remaining overrides at the end; it's valid JSON
        // one way or the other.

        //noinspection unchecked
        Iterator<Map.Entry<String, Object>> sortedOverrides =
                ((Map<String, Object>) OrderedJson.ordered(deserState.overrides)).entrySet().iterator();

        Map.Entry<String, Object> nextOverride = sortedOverrides.hasNext() ? sortedOverrides.next() : null;

        JsonToken token;
        while ((token = parser.nextToken()) != JsonToken.END_OBJECT) {
            assert token == JsonToken.FIELD_NAME;

            String field = parser.getText();
            if (deserState.overrides.containsKey(field)) {
                // There's an override for this entry; skip it
                token = parser.nextToken();
                if (token.isStructStart()) {
                    parser.skipChildren();
                }
            } else {
                // Write all overrides which sort prior to this field
                while (nextOverride != null && OrderedJson.KEY_COMPARATOR.compare(nextOverride.getKey(), field) < 0) {
                    generator.writeFieldName(nextOverride.getKey());
                    generator.writeObject(nextOverride.getValue());
                    nextOverride = sortedOverrides.hasNext() ? sortedOverrides.next() : null;
                }

                // Copy this field name and value to the generator
                generator.copyCurrentStructure(parser);
            }
            // Both of the above operations leave the current token immediately prior to the next
            // field or the end object token.
        }

        // Write any remaining overrides
        while (nextOverride != null) {
            generator.writeFieldName(nextOverride.getKey());
            generator.writeObject(nextOverride.getValue());
            nextOverride = sortedOverrides.hasNext() ? sortedOverrides.next() : null;
        }

        generator.writeEndObject();
    }
1228077
void writeObject(java.io.ObjectOutputStream out) throws IOException {
        // when using object serialization, write the json bytes
        byte[] bytes = toString().getBytes(StandardCharsets.UTF_8);
        out.writeInt(bytes.length);
        out.write(bytes);
    }
597121
public void write(JsonGenerator jsonGenerator) throws IOException {
    jsonGenerator.writeStartObject();

    jsonGenerator.writeFieldName("idToRequest");
    jsonGenerator.writeStartObject();
    for (Integer id : idToRequest.keySet()) {
      jsonGenerator.writeFieldName(id.toString());
      idToRequest.get(id).write(jsonGenerator);
    }
    jsonGenerator.writeEndObject();

    // idToPendingRequests is the same, and we only need to persist the
    // array of pending request ids
    jsonGenerator.writeFieldName("idToPendingRequests");
    jsonGenerator.writeStartArray();
    for (Integer id : idToPendingRequests.keySet()) {
      jsonGenerator.writeNumber(id);
    }
    jsonGenerator.writeEndArray();

    jsonGenerator.writeFieldName("idToGrant");
    jsonGenerator.writeStartObject();
    for (Integer id : idToGrant.keySet()) {
      jsonGenerator.writeObjectField(id.toString(), idToGrant.get(id));
    }
    jsonGenerator.writeEndObject();

    jsonGenerator.writeObjectField("status", status);

    jsonGenerator.writeStringField("sessionId", sessionId);

    jsonGenerator.writeBooleanField("deleted", deleted);

    jsonGenerator.writeNumberField("deletedTime", deletedTime);

    jsonGenerator.writeObjectField("info", info);
    
    jsonGenerator.writeNumberField("startTime", startTime);

    jsonGenerator.writeFieldName("poolInfo");
    poolInfo.write(jsonGenerator);

    jsonGenerator.writeFieldName("typeToFirstWait");
    jsonGenerator.writeStartObject();
    for (ResourceType resourceType : typeToFirstWait.keySet()) {
      Long wait = typeToFirstWait.get(resourceType);
      if (wait == null) {
        wait = new Long(-1);
      }
      jsonGenerator.writeNumberField(resourceType.toString(), wait);
    }
    jsonGenerator.writeEndObject();

    jsonGenerator.writeObjectField("expectedInfo", expectedInfo);
    
    jsonGenerator.writeObjectField("lastHeartbeat", lastHeartbeat);
    
    jsonGenerator.writeNumberField("lastSyncTime", lastSyncTime);

    jsonGenerator.writeEndObject();
    // No need to serialize lastHeartbeatTime, it will be reset.
    // typeToContext can be rebuilt
  }
281583
public <T> void write(final PrintWriter writer, final T object,
			final DataTypeDescriptor<T> descriptor, final boolean indent) throws IOException {
		if (writer == null) throw new NullPointerException("writer");
		if (descriptor == null) throw new NullPointerException("descriptor");

		JsonGenerator generator = factory.createGenerator(writer);
		if (indent) {
			generator.useDefaultPrettyPrinter();
		}

		write(object, descriptor, generator);
		generator.flush();
	}
1292982
public void write(JsonGenerator jsonGenerator) throws IOException {
    jsonGenerator.writeStartObject();

    jsonGenerator.writeStringField("handle", handle);

    jsonGenerator.writeStringField("host", host);

    jsonGenerator.writeNumberField("port", port);

    jsonGenerator.writeNumberField("numPendingCalls", pendingCalls.size());

    jsonGenerator.writeFieldName("pendingCalls");
    jsonGenerator.writeStartArray();
    for (TBase call : pendingCalls) {
      jsonGenerator.writeStartObject();

      // TBase is an abstract class. While reading back, we want to know
      // what kind of object we actually wrote. Jackson does provide two methods
      // to do it automatically, but one of them adds types at a lot of places
      // where we don't need it, and hence our parsing would be required to be
      // changed. The other required adding an annotation to the TBase class,
      // which we can't do, since it is auto-generated by Thrift.
      String callType = call.getClass().getName();
      jsonGenerator.writeStringField("callType", callType);

      jsonGenerator.writeObjectField("call", call);

      jsonGenerator.writeEndObject();
    }
    jsonGenerator.writeEndArray();

    jsonGenerator.writeEndObject();
  }
371011
public JsonWriter endObject() throws IOException {
      checkAndPop(JsonTokenType.BEGIN_OBJECT);
      popIf(JsonTokenType.NAME);
      writer.endObject();
      return this;
   }
1296163
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
        // Write out capacity and any hidden stuff
        s.defaultWriteObject();
    }
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();
    }
886759
public void writeJSON(JSONValue jc, JSONWriter jb, boolean writeClass)
            throws IOException {
        String key;
        Object value;
        jb.objectBegin();
        for (Map.Entry<String, Object> entry : objectMap.entrySet()) {
            key = entry.getKey();
            jb.objectItem(key);
            value = entry.getValue();
            if (value == null)
                jb.valueNull();
            else
                jc.writeValue(value, jb, writeClass);
        }
        jb.objectEnd();
    }
1020413
public JSONWriter objectEnd() throws IOException {
        writer.write(JSON.RBRACE);
        state = stack.pop();
        return this;
    }
236213
def save_json(object, handle, indent=2):
    """"""
    obj_json = json.dumps(object, indent=indent, cls=NumpyJSONEncoder)
    handle.write(obj_json)
907400
private void writeObject(ObjectOutputStream stream) throws IOException {
        Utils.mapper().writeValue((DataOutput) stream, jsonObject);
    }
333788
def write(self, obj):
        
        accept = self.request.headers.get("Accept")
        if "json" in accept:
            if JsonDefaultHandler.__parser is None:
                JsonDefaultHandler.__parser = Parser()
            super(JsonDefaultHandler, self).write(JsonDefaultHandler.__parser.encode(obj))
            return
        # If we are not in json mode
        super(JsonDefaultHandler, self).write(obj)