Write the GeoJSON properties.

@param jsonGenerator
@param rs
@throws IOException
493611
private void writeProperties(JsonGenerator jsonGenerator, ResultSet rs) throws IOException, SQLException {
        if (columnCountProperties != -1) {
            jsonGenerator.writeObjectFieldStart("properties");
            for (Map.Entry<String, Integer> entry : cachedColumnNames.entrySet()) {
                String string = entry.getKey();
                string = string.toLowerCase();
                Integer fieldId = entry.getValue();
                if (rs.getObject(fieldId) instanceof Object[]) {
                    Object[] array = (Object[]) rs.getObject(fieldId);
                    jsonGenerator.writeArrayFieldStart(string);
                    writeArray(jsonGenerator, array, true);
                    jsonGenerator.writeEndArray();
                } else if (rs.getObject(fieldId) != null && rs.getObject(fieldId).equals("{}")){
                    jsonGenerator.writeObjectFieldStart(string);
                    jsonGenerator.writeEndObject();
                } else if (rs.getObject(fieldId) == "null") {
                    jsonGenerator.writeFieldName(string);
                    jsonGenerator.writeNull();
                } else {
                    jsonGenerator.writeObjectField(string, rs.getObject(fieldId));
                }
            }
            jsonGenerator.writeEndObject();
        }
    }
734116
public static void writeGenerators( IGeneratorSet generators, OutputStream outputStream)
    {
    try( GeneratorSetJsonWriter writer = new GeneratorSetJsonWriter( outputStream))
      {
      writer.write( generators);
      }
    catch( Exception e)
      {
      throw new RuntimeException( "Can't write generator definitions", e);
      }
    }
585362
public static void writeJson(Serializable serializable, OutputStream output)
			throws IOException {
		TransportFormat.JSON.writeSerializableTo(serializable, output);
	}
621611
function writeJson( row ){
    let targetDir = path.join(dataDir, wofIdToPath(row.id).join(path.sep));
    try {
      fs.ensureDirSync(targetDir);
      fs.writeFileSync( path.join(targetDir, `${row.id}.geojson`), row.body, 'utf8' );
    } catch( error ){
      if( error ){ console.error(`error making directory ${targetDir}`); }
    }
  }
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();
    }
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();
    }
644738
public static void exportJson(JsonWriter writer, Resource resource)
            throws RepositoryException, IOException {
        exportJson(writer, resource, MappingRules.getDefaultMappingRules());
    }
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
  }
526072
public static void writeJsonProperty(JsonWriter writer, String name,
                                         Object value, MappingRules mapping)
            throws RepositoryException, IOException {
        if (name != null && value != null) {
            int type = PropertyType.STRING;
            if (value instanceof Boolean) {
                type = PropertyType.BOOLEAN;
            } else if (value instanceof Long || value instanceof Integer) {
                type = PropertyType.LONG;
            } else if (value instanceof Double || value instanceof Float) {
                type = PropertyType.DOUBLE;
            } else if (value instanceof BigDecimal) {
                type = PropertyType.DECIMAL;
            } else if (value instanceof Calendar) {
                type = PropertyType.DATE;
            }
            if (mapping.propertyFormat.scope != MappingRules.PropertyFormat.Scope.value) {
                writer.beginObject();
            }
            if (mapping.propertyFormat.scope == MappingRules.PropertyFormat.Scope.value) {
                writer.name(name);
            } else {
                writer.name("name").value(name);
                writer.name("value");
            }
            if (value instanceof Object[]) {
                writer.beginArray();
                for (Object val : (Object[]) value) {
                    JsonUtil.writeJsonValue(writer, null, name, val, type, mapping);
                }
                writer.endArray();
            } else {
                JsonUtil.writeJsonValue(writer, null, name, value, type, mapping);
            }
            if (mapping.propertyFormat.scope != MappingRules.PropertyFormat.Scope.value) {
                writer.name("type").value(PropertyType.nameFromValue(type));
                writer.name("multi").value(value instanceof Object[]);
                writer.endObject();
            }
        }
    }
650180
public static void writeJson(@javax.annotation.Nonnull final OutputStream out, final Object obj) throws IOException {
    final ObjectMapper mapper = new ObjectMapper().enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL)
      .enable(SerializationFeature.INDENT_OUTPUT);
    @javax.annotation.Nonnull final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    mapper.writeValue(buffer, obj);
    out.write(buffer.toByteArray());
  }
1034076
public static void write(JsonElement element, JsonWriter writer) throws IOException {
    TypeAdapters.JSON_ELEMENT.write(writer, element);
  }
252154
protected void write(JsonWriter out, T value, TypeAdapter<JsonElement> elementAdapter, TypeAdapter<T> delegate) throws IOException {
        JsonElement tree = delegate.toJsonTree(value);
        beforeWrite(value, tree);
        elementAdapter.write(out, tree);
    }
976680
public static void saveJson(File json, Object object) throws IOException {
        objectMapper.writer().writeValue(json, object);
    }
695949
public void write(JsonWriter json, UserDto user, Collection<String> groups, @Nullable Collection<String> fields) {
    json.beginObject();
    json.prop(FIELD_LOGIN, user.getLogin());
    writeIfNeeded(json, user.getName(), FIELD_NAME, fields);
    if (userSession.isLoggedIn()) {
      writeIfNeeded(json, user.getEmail(), FIELD_EMAIL, fields);
      writeIfNeeded(json, user.isActive(), FIELD_ACTIVE, fields);
      writeIfNeeded(json, user.isLocal(), FIELD_LOCAL, fields);
      writeIfNeeded(json, user.getExternalLogin(), FIELD_EXTERNAL_IDENTITY, fields);
      writeIfNeeded(json, user.getExternalIdentityProvider(), FIELD_EXTERNAL_PROVIDER, fields);
      writeGroupsIfNeeded(json, groups, fields);
      writeScmAccountsIfNeeded(json, fields, user);
    }
    json.endObject();
  }
1141613
public static <T> void writeTo(Writer writer, T message, Schema<T> schema,
            boolean numeric) throws IOException
    {
        final JsonGenerator generator = DEFAULT_JSON_FACTORY.createJsonGenerator(writer);
        try
        {
            writeTo(generator, message, schema, numeric);
        }
        finally
        {
            generator.close();
        }
    }
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();
        }
    }
921110
private void writePropertyData() {
		try (PrintStream out = new PrintStream(openResultFileOuputStream(
				resultDirectory, "properties.json"))) {
			out.println("{");

			int count = 0;
			for (Entry<Integer, PropertyRecord> propertyEntry : this.propertyRecords
					.entrySet()) {
				if (count > 0) {
					out.println(",");
				}
				out.print("\"" + propertyEntry.getKey() + "\":");
				mapper.writeValue(out, propertyEntry.getValue());
				count++;
			}
			out.println("\n}");

			System.out.println(" Serialized information for " + count
					+ " properties.");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}