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


Java JsonGenerator.writeRaw方法代码示例

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


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

示例1: writeInternal

import org.codehaus.jackson.JsonGenerator; //导入方法依赖的package包/类
@Override
protected void writeInternal(Object object, HttpOutputMessage outputMessage)
		throws IOException, HttpMessageNotWritableException {

	JsonEncoding encoding = getJsonEncoding(outputMessage.getHeaders().getContentType());
	JsonGenerator jsonGenerator =
			this.objectMapper.getJsonFactory().createJsonGenerator(outputMessage.getBody(), encoding);

	// A workaround for JsonGenerators not applying serialization features
	// https://github.com/FasterXML/jackson-databind/issues/12
	if (this.objectMapper.getSerializationConfig().isEnabled(SerializationConfig.Feature.INDENT_OUTPUT)) {
		jsonGenerator.useDefaultPrettyPrinter();
	}

	try {
		if (this.jsonPrefix != null) {
			jsonGenerator.writeRaw(this.jsonPrefix);
		}
		this.objectMapper.writeValue(jsonGenerator, object);
	}
	catch (JsonProcessingException ex) {
		throw new HttpMessageNotWritableException("Could not write JSON: " + ex.getMessage(), ex);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:MappingJacksonHttpMessageConverter.java

示例2: writeInternal

import org.codehaus.jackson.JsonGenerator; //导入方法依赖的package包/类
@Override
protected void writeInternal(Object object, HttpOutputMessage outputMessage)
		throws IOException, HttpMessageNotWritableException {

	JsonEncoding encoding = getJsonEncoding(outputMessage.getHeaders().getContentType());
	JsonGenerator jsonGenerator =
			this.objectMapper.getJsonFactory().createJsonGenerator(outputMessage.getBody(), encoding);
	try {
		if (this.prefixJson) {
			jsonGenerator.writeRaw("{} && ");
		}
		this.objectMapper.writeValue(jsonGenerator, object);
	}
	catch (IOException ex) {
		throw new HttpMessageNotWritableException("Could not write JSON: " + ex.getMessage(), ex);
	}
}
 
开发者ID:bestarandyan,项目名称:ShoppingMall,代码行数:18,代码来源:MappingJacksonHttpMessageConverter.java

示例3: writeInternal

import org.codehaus.jackson.JsonGenerator; //导入方法依赖的package包/类
@Override
protected void writeInternal(Object o, HttpOutputMessage outputMessage)
		throws IOException, HttpMessageNotWritableException {
	JsonEncoding encoding = getEncoding(outputMessage.getHeaders()
			.getContentType());
	JsonGenerator jsonGenerator = this.objectMapper.getJsonFactory()
			.createJsonGenerator(outputMessage.getBody(), encoding);
	if (this.prefixJson) {
		jsonGenerator.writeRaw("{} && ");
	}
	this.objectMapper.writeValue(jsonGenerator, o);
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	JsonGenerator baosjsonGenerator = this.objectMapper.getJsonFactory()
			.createJsonGenerator(baos, encoding);
	this.objectMapper.writeValue(baosjsonGenerator, o);
	logger.debug("Middleware returns " + o.getClass().getName() + " "
			+ baos.toString());
}
 
开发者ID:Appverse,项目名称:appverse-server,代码行数:19,代码来源:CustomMappingJacksonHttpMessageConverter.java

示例4: writeIndentation

import org.codehaus.jackson.JsonGenerator; //导入方法依赖的package包/类
@Override
public void writeIndentation(JsonGenerator jg, int level)
{
    try
    {
        if (!compact)
        {
            jg.writeRaw(eol);
            if (level > 0)
            { // should we err on negative values (as there's some flaw?)
                level *= charsPerLevel;
                while (level > indents.length)
                { // unlike to happen but just in case
                    jg.writeRaw(indents, 0, indents.length);
                    level -= indents.length;
                }
                jg.writeRaw(indents, 0, level);
            }
        }
        else
        {
            jg.writeRaw(space);
        }
    }
    catch (IOException e)
    {
        e.printStackTrace();
        System.exit(1);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:31,代码来源:JsonTransformer.java


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