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


Java JsonGenerator.writeRaw方法代码示例

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


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

示例1: testSurrogatesWithRaw

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
public void testSurrogatesWithRaw() throws Exception
{
    final String VALUE = quote("\ud83d\ude0c");
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    JsonGenerator g = JSON_F.createGenerator(ObjectWriteContext.empty(), out);
    g.writeStartArray();
    g.writeRaw(VALUE);
    g.writeEndArray();
    g.close();

    final byte[] JSON = out.toByteArray();

    JsonParser jp = JSON_F.createParser(ObjectReadContext.empty(), JSON);
    assertToken(JsonToken.START_ARRAY, jp.nextToken());
    assertToken(JsonToken.VALUE_STRING, jp.nextToken());
    String str = jp.getText();
    assertEquals(2, str.length());
    assertEquals((char) 0xD83D, str.charAt(0));
    assertEquals((char) 0xDE0C, str.charAt(1));
    assertToken(JsonToken.END_ARRAY, jp.nextToken());
    jp.close();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:TestUtf8Generator.java

示例2: OutputStreamDemo

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
public static void OutputStreamDemo() throws IOException {
    String out = "";
    JsonFactory f = new JsonFactory();
    FileOutputStream fos = new FileOutputStream(new File("user.out.json"));
    JsonGenerator g = f.createGenerator(fos);

    g.writeStartObject();
    g.writeObjectFieldStart("name");
    g.writeStringField("first", "BorLion");
    g.writeStringField("last", "Zhu");
    g.writeEndObject(); // for field 'name'
    g.writeStringField("gender", "MALE");
    g.writeBooleanField("verified", true);
    g.writeBinaryField("userImage", "Rm9vYmFyIQ==".getBytes());
    g.writeEndObject();
    g.writeRaw('\n');
    g.close();

}
 
开发者ID:zhubl,项目名称:planless,代码行数:20,代码来源:Main.java

示例3: writeValue

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void writeValue(Any message, JsonGenerator gen) throws IOException {
  if (message.equals(Any.getDefaultInstance())) {
    // Note: empty Any is not indented the same way as an empty message, this is likely an
    // upstream bug.
    gen.writeRaw(": {}");
    return;
  }
  gen.writeStartObject();
  String typeUrl = message.getTypeUrl();
  TypeSpecificMarshaller<?> serializer = marshallerRegistry.findByTypeUrl(typeUrl);
  gen.writeFieldName("@type");
  gen.writeString(typeUrl);
  if (serializer instanceof WellKnownTypeMarshaller) {
    gen.writeFieldName("value");
    serializer.writeValue(message.getValue(), gen);
  } else {
    serializer.doWrite(message.getValue(), gen);
  }
  gen.writeEndObject();
}
 
开发者ID:curioswitch,项目名称:curiostack,代码行数:22,代码来源:WellKnownTypeMarshaller.java

示例4: writeEndObject

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void writeEndObject(JsonGenerator g, int nrOfEntries) throws IOException {
    if (!this._objectIndenter.isInline()) {
        --this._nesting;
    }

    if (nrOfEntries > 0) {
        this._objectIndenter.writeIndentation(g, this._nesting);
    } else {
        // lets disable the space in empty objects
        //g.writeRaw(' ');
    }

    g.writeRaw('}');
}
 
开发者ID:fabric8-updatebot,项目名称:updatebot,代码行数:16,代码来源:NpmJsonPrettyPrinter.java

示例5: writeRootValueSeparator

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void writeRootValueSeparator(JsonGenerator g) throws IOException
{
    if (_rootValueSeparator != null) {
        g.writeRaw(_rootValueSeparator);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:MinimalPrettyPrinter.java

示例6: writeObjectFieldValueSeparator

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void writeObjectFieldValueSeparator(JsonGenerator jg)
        throws IOException, JsonGenerationException {
    /**
     * Custom object separator (Default is " : ") to make it easier to compare state dumps with other
     * ethereum client implementations
     */
    jg.writeRaw(": ");
}
 
开发者ID:talentchain,项目名称:talchain,代码行数:10,代码来源:EtherObjectMapper.java

示例7: writeInternal

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

	JsonEncoding encoding = getJsonEncoding(outputMessage.getHeaders().getContentType());
	// The following has been deprecated as late as Jackson 2.2 (April 2013);
	// preserved for the time being, for Jackson 2.0/2.1 compatibility.
	@SuppressWarnings("deprecation")
	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.isEnabled(SerializationFeature.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,代码行数:28,代码来源:MappingJackson2HttpMessageConverter.java

示例8: writeEndObject

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void writeEndObject(JsonGenerator jg, int nrOfEntries) throws IOException {
  if (!_objectIndenter.isInline()) {
    --_nesting;
  }
  _objectIndenter.writeIndentation(jg, _nesting);
  jg.writeRaw('}');
}
 
开发者ID:curioswitch,项目名称:curiostack,代码行数:9,代码来源:MessageMarshaller.java

示例9: writeIndentation

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
public void writeIndentation(JsonGenerator jg, int level) throws IOException, JsonGenerationException {
	jg.writeRaw(SYSTEM_LINE_SEPARATOR);
	if (level > 0) {
		level += level; // 2 spaces per level
		while (level > SPACE_COUNT) { // should never happen but...
			jg.writeRaw(SPACES, 0, SPACE_COUNT);
			level -= SPACES.length;
		}
		jg.writeRaw(SPACES, 0, level);
	}
}
 
开发者ID:mvetsch,项目名称:JWT4B,代码行数:12,代码来源:Lf2SpacesIndenter.java

示例10: writeStartObject

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void writeStartObject(JsonGenerator g) throws IOException
{
    g.writeRaw('{');
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:MinimalPrettyPrinter.java

示例11: writeEndObject

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void writeEndObject(JsonGenerator g, int nrOfEntries) throws IOException
{
    g.writeRaw('}');
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:MinimalPrettyPrinter.java

示例12: writeStartArray

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void writeStartArray(JsonGenerator g) throws IOException
{
    g.writeRaw('[');
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:MinimalPrettyPrinter.java

示例13: writeEndArray

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void writeEndArray(JsonGenerator g, int nrOfValues) throws IOException
{
    g.writeRaw(']');
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:MinimalPrettyPrinter.java

示例14: writeObjectFieldValueSeparator

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void writeObjectFieldValueSeparator(JsonGenerator jg) throws IOException {
  jg.writeRaw(": ");
}
 
开发者ID:curioswitch,项目名称:curiostack,代码行数:5,代码来源:MessageMarshaller.java

示例15: writeEndArray

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void writeEndArray(JsonGenerator gen, int nrOfValues) throws IOException {
  gen.writeRaw(']');
}
 
开发者ID:curioswitch,项目名称:curiostack,代码行数:5,代码来源:MessageMarshaller.java


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