Write each of the bytes in a kim with Huffman encoding.

@param kim
A kim containing the bytes to be written.
@param huff
The Huffman encoder.
@param ext
The Huffman encoder for the extended bytes.
@throws JSONException
432796
private void write(Kim kim, Huff huff, Huff ext) throws JSONException {
        for (int at = 0; at < kim.length; at += 1) {
            int c = kim.get(at);
            write(c, huff);
            while ((c & 128) == 128) {
                at += 1;
                c = kim.get(at);
                write(c, ext);
            }
        }
    }
384467
public void write(JsonGenerator jsonGenerator) throws IOException {
    jsonGenerator.writeStartObject();

    // clusterNodeInfo begins
    jsonGenerator.writeFieldName("clusterNodeInfo");
    jsonGenerator.writeStartObject();
    jsonGenerator.writeStringField("name", clusterNodeInfo.name);
    jsonGenerator.writeObjectField("address", clusterNodeInfo.address);
    jsonGenerator.writeObjectField("total", clusterNodeInfo.total);
    jsonGenerator.writeObjectField("free", clusterNodeInfo.free);
    jsonGenerator.writeObjectField("resourceInfos",
      clusterNodeInfo.resourceInfos);
    jsonGenerator.writeEndObject();
    // clusterNodeInfo ends

    // grants begins
    jsonGenerator.writeFieldName("grants");
    jsonGenerator.writeStartObject();
    for (Map.Entry<GrantId, ResourceRequestInfo> entry : grants.entrySet()) {
      jsonGenerator.writeFieldName(entry.getKey().unique);
      jsonGenerator.writeStartObject();
      jsonGenerator.writeFieldName("grantId");
      entry.getKey().write(jsonGenerator);
      jsonGenerator.writeFieldName("grant");
      entry.getValue().write(jsonGenerator);
      jsonGenerator.writeEndObject();
    }
    jsonGenerator.writeEndObject();
    // grants ends

    jsonGenerator.writeEndObject();
    // We skip the hostNode and lastHeartbeatTime as they need not be persisted.
    // resourceTypeToMaxCpu and resourceTypeToStatsMap can be rebuilt using the
    // conf and the grants respectively.
  }
408966
@Override
  public void writeExternal(ObjectOutput out) throws IOException {
    super.writeExternal(out);
    out.writeObject(knnDistance);
  }
1009220
private void writeString(String string) throws JSONException {

// Special case for empty strings.

        if (string.length() == 0) {
            zero();
            write(end, this.stringhuff);
        } else {
            Kim kim = new Kim(string);

// Look for the string in the strings keep. If it is found, emit its
// integer and count that as a use.

            int integer = this.stringkeep.find(kim);
            if (integer != none) {
                one();
                write(integer, this.stringkeep);
            } else {

// But if it is not found, emit the string's characters. Register the string
// so that a later lookup can succeed.

                zero();
                write(kim, this.stringhuff, this.stringhuffext);
                write(end, this.stringhuff);
                this.stringkeep.register(kim);
            }
        }
    }
672277
void writeExtensionByte(int extensionType, int value) throws IOException {
        output.write(FIX_EXT_1);
        output.write(extensionType);
        output.write(value);
    }
263876
private void write(LineString geom, JsonGenerator gen) throws IOException {
        gen.writeStringField("type", "LineString");
        gen.writeFieldName("coordinates");
        writeCoordinates(geom.getCoordinates(), gen);
    }
579674
@Override
    protected void write(JsonGenerator g, JacksonJrsTreeCodec codec) throws IOException
    {
        g.writeStartObject();
        if (!_values.isEmpty()) {
            for (Map.Entry<String,JrsValue> entry : _values.entrySet()) {
                g.writeFieldName(entry.getKey());
                codec.writeTree(g, entry.getValue());
            }
        }
        g.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);
    }
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();
    }
646685
public void write(JsonGenerator jsonGenerator) throws IOException {
    jsonGenerator.writeStartObject();

    // nameToNode begins
    jsonGenerator.writeFieldName("nameToNode");
    jsonGenerator.writeStartObject();
    for (Map.Entry<String, ClusterNode> entry : nameToNode.entrySet()) {
      jsonGenerator.writeFieldName(entry.getKey());
      entry.getValue().write(jsonGenerator);
    }
    jsonGenerator.writeEndObject();
    // nameToNode ends

    // hostsToSessions begins
    // We create a new Map of type <ClusterNode.name, Set<SessionIds>>.
    // The original hostsToSessions map has the ClusterNode as its key, and
    // we do not need to persist the entire ClusterNode again, since we have
    // already done that with nameToNode.
    Map<String, Set<String>> hostsToSessionsMap =
      new HashMap<String, Set<String>>();
    for (Map.Entry<ClusterNode, Set<String>> entry :
      hostsToSessions.entrySet()) {
      hostsToSessionsMap.put(entry.getKey().getName(),
        entry.getValue());
    }
    jsonGenerator.writeObjectField("hostsToSessions", hostsToSessionsMap);
    // hostsToSessions ends

    jsonGenerator.writeObjectField("nameToApps", nameToApps);

    // faultManager is not required

    // We can rebuild the loadManager
    jsonGenerator.writeEndObject();
  }
786751
private void writeIndention(Writer writer, int indentDepth)
    throws IOException
    {
        if (logger.isLoggable(Level.FINER)) logger.entering(className, "writeIndention(Writer, int)");

        try
        {
            for (int i = 0; i < indentDepth; i++) 
            {
                writer.write(indent);
            }
        }
        catch (Exception ex)
        {
            IOException iox = new IOException("Error occurred on serialization of JSON text.");
            iox.initCause(ex);
            throw iox;
        }

        if (logger.isLoggable(Level.FINER)) logger.exiting(className, "writeIndention(Writer, int)");
    }
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);
		}
	}
1013119
@Override
    public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException {
	out.writeObject(new LinkedHashMap(this));
    }
472678
def write_json(self, **kwargs):
        
        self.stdout.write(json.dumps(kwargs) + "\n")
        self.stdout.flush()
89416
@SuppressWarnings("deprecation")
  public static void writeFlowDetails(JsonGenerator jsonGenerator, Flow aFlow,
      DetailLevel selectedSerialization, Predicate<String> includeFilter)
      throws JsonGenerationException, IOException {
    jsonGenerator.writeStartObject();
    // serialize the FlowKey object
    filteredWrite("flowKey", includeFilter, aFlow.getFlowKey(), jsonGenerator);

    // serialize individual members of this class
    filteredWrite("flowName", includeFilter, aFlow.getFlowName(), jsonGenerator);
    filteredWrite("userName", includeFilter, aFlow.getUserName(), jsonGenerator);
    filteredWrite("jobCount", includeFilter, aFlow.getJobCount(), jsonGenerator);
    filteredWrite("totalMaps", includeFilter, aFlow.getTotalMaps(), jsonGenerator);
    filteredWrite("totalReduces", includeFilter, aFlow.getTotalReduces(), jsonGenerator);
    filteredWrite("mapFileBytesRead", includeFilter, aFlow.getMapFileBytesRead(), jsonGenerator);
    filteredWrite("mapFileBytesWritten", includeFilter, aFlow.getMapFileBytesWritten(), jsonGenerator);
    filteredWrite("reduceFileBytesRead", includeFilter, aFlow.getReduceFileBytesRead(), jsonGenerator);
    filteredWrite("hdfsBytesRead", includeFilter, aFlow.getHdfsBytesRead(), jsonGenerator);
    filteredWrite("hdfsBytesWritten", includeFilter, aFlow.getHdfsBytesWritten(), jsonGenerator);
    filteredWrite("mapSlotMillis", includeFilter, aFlow.getMapSlotMillis(), jsonGenerator);
    filteredWrite("reduceSlotMillis", includeFilter, aFlow.getReduceSlotMillis(), jsonGenerator);
    filteredWrite("megabyteMillis", includeFilter, aFlow.getMegabyteMillis(), jsonGenerator);
    filteredWrite("cost", includeFilter, aFlow.getCost(), jsonGenerator);
    filteredWrite("reduceShuffleBytes", includeFilter, aFlow.getReduceShuffleBytes(), jsonGenerator);
    filteredWrite("duration", includeFilter, aFlow.getDuration(), jsonGenerator);
    filteredWrite("wallClockTime", includeFilter, aFlow.getWallClockTime(), jsonGenerator);
    filteredWrite("cluster", includeFilter, aFlow.getCluster(), jsonGenerator);
    filteredWrite("appId", includeFilter, aFlow.getAppId(), jsonGenerator);
    filteredWrite("runId", includeFilter, aFlow.getRunId(), jsonGenerator);
    filteredWrite("version", includeFilter, aFlow.getVersion(), jsonGenerator);
    filteredWrite("hadoopVersion", includeFilter, aFlow.getHadoopVersion(), jsonGenerator);
    if (selectedSerialization == SerializationContext.DetailLevel.EVERYTHING) {
      filteredWrite("submitTime", includeFilter, aFlow.getSubmitTime(), jsonGenerator);
      filteredWrite("launchTime", includeFilter, aFlow.getLaunchTime(), jsonGenerator);
      filteredWrite("finishTime", includeFilter, aFlow.getFinishTime(), jsonGenerator);
    }
    filteredWrite(Constants.HRAVEN_QUEUE, includeFilter, aFlow.getQueue(), jsonGenerator);
    filteredWrite("counters", includeFilter, aFlow.getCounters(), jsonGenerator);
    filteredWrite("mapCounters", includeFilter, aFlow.getMapCounters(), jsonGenerator);
    filteredWrite("reduceCounters", includeFilter, aFlow.getReduceCounters(), jsonGenerator);

    // if flag, include job details
    if ((selectedSerialization == SerializationContext.DetailLevel.FLOW_SUMMARY_STATS_WITH_JOB_STATS)
        || (selectedSerialization == SerializationContext.DetailLevel.EVERYTHING)) {
      jsonGenerator.writeFieldName("jobs");
      jsonGenerator.writeObject(aFlow.getJobs());
    }
    jsonGenerator.writeEndObject();

  }
591620
private void writeValue(Object value) throws JSONException {
        if (value instanceof Number) {
            String string = JSONObject.numberToString((Number) value);
            int integer = this.valuekeep.find(string);
            if (integer != none) {
                write(2, 2);
                write(integer, this.valuekeep);
                return;
            }
            if (value instanceof Integer || value instanceof Long) {
                long longer = ((Number) value).longValue();
                if (longer >= 0 && longer < int14) {
                    write(0, 2);
                    if (longer < int4) {
                        zero();
                        write((int) longer, 4);
                        return;
                    }
                    one();
                    if (longer < int7) {
                        zero();
                        write((int)(longer - int4), 7);
                        return;
                    }
                    one();
                    write((int)(longer - int7), 14);
                    return;
                }
            }
            write(1, 2);
            for (int i = 0; i < string.length(); i += 1) {
                write(bcd(string.charAt(i)), 4);
            }
            write(endOfNumber, 4);
            this.valuekeep.register(string);
        } else {
            write(3, 2);
            writeJSON(value);
        }
    }
1225319
@Override
    public void writeExternal(ObjectOutput s) throws IOException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
            Tr.event(this, tc, "Serializing " + this);
        }
        super.writeExternal(s);
    }