当前位置: 首页>>代码示例>>Java>>正文


Java ObjectWriter.writeValue方法代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.ObjectWriter.writeValue方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectWriter.writeValue方法的具体用法?Java ObjectWriter.writeValue怎么用?Java ObjectWriter.writeValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.fasterxml.jackson.databind.ObjectWriter的用法示例。


在下文中一共展示了ObjectWriter.writeValue方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: write

import com.fasterxml.jackson.databind.ObjectWriter; //导入方法依赖的package包/类
public static void write(SecurityAnalysisResult result, Writer writer) throws IOException {
    Objects.requireNonNull(result);
    Objects.requireNonNull(writer);

    ObjectMapper objectMapper = new ObjectMapper();
    SimpleModule module = new SimpleModule();
    module.addSerializer(SecurityAnalysisResult.class, new SecurityAnalysisResultSerializer());
    module.addSerializer(NetworkMetadata.class, new NetworkMetadataSerializer());
    module.addSerializer(PostContingencyResult.class, new PostContingencyResultSerializer());
    module.addSerializer(LimitViolationsResult.class, new LimitViolationsResultSerializer());
    module.addSerializer(LimitViolation.class, new LimitViolationSerializer());
    module.addSerializer(ContingencyElement.class, new ContingencyElementSerializer());
    objectMapper.registerModule(module);

    ObjectWriter objectWriter = objectMapper.writerWithDefaultPrettyPrinter();
    objectWriter.writeValue(writer, result);

}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:19,代码来源:SecurityAnalysisResultSerializer.java

示例2: write

import com.fasterxml.jackson.databind.ObjectWriter; //导入方法依赖的package包/类
private static void write(Contingency object, Path jsonFile) {
    Objects.requireNonNull(object);
    Objects.requireNonNull(jsonFile);

    try (OutputStream os = Files.newOutputStream(jsonFile)) {
        ObjectMapper mapper = new ObjectMapper();
        SimpleModule module = new SimpleModule();
        module.addSerializer(ContingencyElement.class, new ContingencyElementSerializer());
        mapper.registerModule(module);

        ObjectWriter writer = mapper.writerWithDefaultPrettyPrinter();
        writer.writeValue(os, object);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:17,代码来源:ContingencyJsonTest.java

示例3: saveProfile

import com.fasterxml.jackson.databind.ObjectWriter; //导入方法依赖的package包/类
public void saveProfile() throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    ObjectWriter ow = mapper.writer().withDefaultPrettyPrinter();
    ow.writeValue(new File(profileFileName), localClient().getProfile());
}
 
开发者ID:ripreal,项目名称:V8LogScanner,代码行数:6,代码来源:ClientsManager.java

示例4: close

import com.fasterxml.jackson.databind.ObjectWriter; //导入方法依赖的package包/类
@Override
public void close() throws IOException {
    try {
        final EncryptedDataContainer encrypted = cipher.doFinal();
        super.write(encrypted.getContent());
        final String tag = CryptoUtils.byteArrayToString(encrypted.getTag());
        final ObjectReader reader = session.getClient().getJSON().getContext(null).readerFor(FileKey.class);
        final FileKey fileKey = reader.readValue(status.getFilekey().array());
        fileKey.setTag(tag);
        final ObjectWriter writer = session.getClient().getJSON().getContext(null).writerFor(FileKey.class);
        final ByteArrayOutputStream out = new ByteArrayOutputStream();
        writer.writeValue(out, fileKey);
        status.setFilekey(ByteBuffer.wrap(out.toByteArray()));
    }
    catch(CryptoSystemException e) {
        throw new IOException(e);
    }
    finally {
        super.close();
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:22,代码来源:CryptoOutputStream.java

示例5: pre

import com.fasterxml.jackson.databind.ObjectWriter; //导入方法依赖的package包/类
@Override
public Void pre(final Transfer.Type type, final Map<Path, TransferStatus> files, final ConnectionCallback callback) throws BackgroundException {
    try {
        switch(type) {
            case download:
                break;
            default:
                if(session.userAccount().isEncryptionEnabled()) {
                    for(Map.Entry<Path, TransferStatus> entry : files.entrySet()) {
                        if(containerService.getContainer(entry.getKey()).getType().contains(Path.Type.vault)) {
                            final TransferStatus status = entry.getValue();
                            final FileKey fileKey = TripleCryptConverter.toSwaggerFileKey(Crypto.generateFileKey());
                            final ObjectWriter writer = session.getClient().getJSON().getContext(null).writerFor(FileKey.class);
                            final ByteArrayOutputStream out = new ByteArrayOutputStream();
                            writer.writeValue(out, fileKey);
                            status.setFilekey(ByteBuffer.wrap(out.toByteArray()));
                        }
                    }
                }
        }
        return null;
    }
    catch(IOException e) {
        throw new DefaultIOExceptionMappingService().map(e);
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:27,代码来源:SDSEncryptionBulkFeature.java

示例6: encode

import com.fasterxml.jackson.databind.ObjectWriter; //导入方法依赖的package包/类
@Override
public void encode(OutputStream out, Object object) throws Exception {
    Class<?> clazz = object.getClass();
    JsonGenerator generator = constructGenerator(out);
    JavaType type = mapper.getTypeFactory().constructType(clazz);
    ObjectWriter writer = mapper.writerFor(type);
    writer.writeValue(generator, object);
    generator.close();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:Jackson2AfterBurnCodec.java

示例7: writeOutErrors

import com.fasterxml.jackson.databind.ObjectWriter; //导入方法依赖的package包/类
/**
 * Write out the errors to a file.
 *
 * @param allErrors The errors to write.
 * @param outFile The location to write.
 */
private void writeOutErrors(AllErrors allErrors, Path outFile) {
	try (Writer writer = Files.newBufferedWriter(outFile)) {
		ObjectWriter jsonObjectWriter = new ObjectMapper()
				.setSerializationInclusion(JsonInclude.Include.NON_NULL)
				.writer()
				.withDefaultPrettyPrinter();
		jsonObjectWriter.writeValue(writer, allErrors);
	} catch (IOException exception) {
		DEV_LOG.error("Could not write out error JSON to file", exception);
	}
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:18,代码来源:ConversionFileWriterWrapper.java

示例8: write

import com.fasterxml.jackson.databind.ObjectWriter; //导入方法依赖的package包/类
public static void write(LoadFlowResult result, Path jsonFile) {
    Objects.requireNonNull(result);
    Objects.requireNonNull(jsonFile);

    try (OutputStream os = Files.newOutputStream(jsonFile)) {
        ObjectMapper objectMapper = new ObjectMapper();
        SimpleModule module = new SimpleModule();
        module.addSerializer(LoadFlowResult.class, new LoadFlowResultSerializer());
        objectMapper.registerModule(module);
        ObjectWriter writer = objectMapper.writerWithDefaultPrettyPrinter();
        writer.writeValue(os, result);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:16,代码来源:LoadFlowResultSerializer.java

示例9: writeInternal

import com.fasterxml.jackson.databind.ObjectWriter; //导入方法依赖的package包/类
@Override
@SuppressWarnings("deprecation")
protected void writeInternal(Object object, Type type, HttpOutputMessage outputMessage)
		throws IOException, HttpMessageNotWritableException {

	JsonEncoding encoding = getJsonEncoding(outputMessage.getHeaders().getContentType());
	JsonGenerator generator = this.objectMapper.getFactory().createGenerator(outputMessage.getBody(), encoding);
	try {

		JavaType javaType = null;
		if (jackson26Available && type != null && object != null && TypeUtils.isAssignable(type, object.getClass())) {
			javaType = getJavaType(type, null);
		}
		ObjectWriter objectWriter;
		objectWriter = this.objectMapper.writer();
		if (javaType != null && javaType.isContainerType()) {
			objectWriter = objectWriter.withType(javaType);
		}
		objectWriter.writeValue(generator, object);

		generator.flush();

	}
	catch (JsonProcessingException ex) {
		throw new HttpMessageNotWritableException("Could not write content: " + ex.getMessage(), ex);
	}
}
 
开发者ID:JetBrains,项目名称:teamcity-hashicorp-vault-plugin,代码行数:28,代码来源:AbstractJackson2HttpMessageConverter.java

示例10: setFileKey

import com.fasterxml.jackson.databind.ObjectWriter; //导入方法依赖的package包/类
private void setFileKey(final TransferStatus status) throws BackgroundException {
    // copy between encrypted and unencrypted data room
    final FileKey fileKey = TripleCryptConverter.toSwaggerFileKey(Crypto.generateFileKey());
    final ObjectWriter writer = session.getClient().getJSON().getContext(null).writerFor(FileKey.class);
    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    try {
        writer.writeValue(out, fileKey);
    }
    catch(IOException e) {
        throw new DefaultIOExceptionMappingService().map(e);
    }
    status.setFilekey(ByteBuffer.wrap(out.toByteArray()));
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:14,代码来源:SDSDelegatingCopyFeature.java

示例11: writeJsonMetric

import com.fasterxml.jackson.databind.ObjectWriter; //导入方法依赖的package包/类
/**
 * serialize a JSON metric over the outputstream in a bulk request
 */
private void writeJsonMetric(JsonMetric jsonMetric, ObjectWriter writer, OutputStream out) throws IOException {
    writer.writeValue(out, new BulkIndexOperationHeader(currentIndexName, jsonMetric.type()));
    out.write("\n".getBytes());
    writer.writeValue(out, jsonMetric);
    out.write("\n".getBytes());

    out.flush();
}
 
开发者ID:oneops,项目名称:oneops,代码行数:12,代码来源:ElasticsearchReporter.java

示例12: write

import com.fasterxml.jackson.databind.ObjectWriter; //导入方法依赖的package包/类
public static void write(ObjectWriter objectWriter, FileObject fileObject, Object object) {
    try (Writer writer = fileObject.openWriter()) {
        objectWriter.writeValue(writer, object);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:Cosium,项目名称:openapi-annotation-processor,代码行数:8,代码来源:SwaggerUtils.java

示例13: encode

import com.fasterxml.jackson.databind.ObjectWriter; //导入方法依赖的package包/类
@Override
public void encode(OutputStream out, Object object) throws Exception {
    Class<?> clazz = object.getClass();
    JsonGenerator generator = constructGenerator(out);
    JavaType type = mapper.getTypeFactory().constructType(clazz);
    ObjectWriter writer = mapper.writerFor(type);
    writer.writeValue(generator, object);
    generator.flush();
    generator.close();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:Jackson2Codec.java

示例14: writeObjectToFile

import com.fasterxml.jackson.databind.ObjectWriter; //导入方法依赖的package包/类
protected void writeObjectToFile(final ObjectWriter objectWriter, final Object object, final File targetFile)
        throws IOException {
    targetFile.getParentFile().mkdirs();
    targetFile.createNewFile();
    objectWriter.writeValue(targetFile, object);
}
 
开发者ID:Microsoft,项目名称:azure-maven-plugins,代码行数:7,代码来源:PackageMojo.java


注:本文中的com.fasterxml.jackson.databind.ObjectWriter.writeValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。