本文整理汇总了Java中com.fasterxml.jackson.core.JsonGenerator.writeNumber方法的典型用法代码示例。如果您正苦于以下问题:Java JsonGenerator.writeNumber方法的具体用法?Java JsonGenerator.writeNumber怎么用?Java JsonGenerator.writeNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.core.JsonGenerator
的用法示例。
在下文中一共展示了JsonGenerator.writeNumber方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serialize
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(JsonGenerator generator) throws IOException {
generator.writeNumber(getCode());
generator.writeNumber(this.requestId);
if (this.subscriptionId != null || this.reason != null) {
generator.writeStartObject();
if (this.reason != null) {
generator.writeStringField("reason", this.reason);
}
if (this.subscriptionId != null) {
generator.writeNumberField("subscription", this.subscriptionId);
}
generator.writeEndObject();
}
}
示例2: serialize
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(JsonGenerator generator) throws IOException {
generator.writeNumber(getCode());
generator.writeString(this.realm);
generator.writeStartObject();
generator.writeObjectFieldStart("roles");
for (WampRole wampRole : this.roles) {
generator.writeObjectFieldStart(wampRole.getRole());
if (wampRole.hasFeatures()) {
generator.writeObjectFieldStart("features");
for (String feature : wampRole.getFeatures()) {
generator.writeBooleanField(feature, true);
}
generator.writeEndObject();
}
generator.writeEndObject();
}
generator.writeEndObject();
generator.writeEndObject();
}
示例3: serialize
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(JsonGenerator generator) throws IOException {
generator.writeNumber(getCode());
generator.writeNumber(this.requestId);
generator.writeNumber(this.registrationId);
generator.writeStartObject();
if (this.caller != null) {
generator.writeNumberField("caller", this.caller.longValue());
}
generator.writeEndObject();
if (this.argumentsKw != null) {
if (this.arguments == null) {
generator.writeStartArray();
generator.writeEndArray();
}
else {
generator.writeObject(this.arguments);
}
generator.writeObject(this.argumentsKw);
}
else if (this.arguments != null) {
generator.writeObject(this.arguments);
}
}
示例4: serialize
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(ValueProvider<?> value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
if (StringValueProvider.class.isAssignableFrom(value.getClass())) {
jgen.writeString((String) value.getValue());
} else if (IntValueProvider.class.isAssignableFrom(value.getClass())) {
jgen.writeNumber((Integer) value.getValue());
} else {
throw new IllegalArgumentException(
String.format("Unsupported value enum type: %s", value.getClass().getName()));
}
}
示例5: serialize
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(Short s, JsonGenerator jGen,
SerializerProvider serializer) throws IOException,
JsonProcessingException {
if (s == null) jGen.writeNull();
else jGen.writeNumber(s.shortValue() & 0xffff);
}
示例6: getJsonFromWrapperLongArray
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
public static void getJsonFromWrapperLongArray(JsonGenerator jg, Long[] array, String pf)
throws JsonGenerationException, IOException {
jg.writeStartArray();
for (Long obj : array) {
jg.writeNumber(obj.longValue());
}
jg.writeEndArray();
}
示例7: serialize
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(T object, String fieldName, boolean writeFieldNameForObject, JsonGenerator jsonGenerator) throws IOException {
if (fieldName != null) {
jsonGenerator.writeNumberField(fieldName, convertToFloat(object));
} else {
jsonGenerator.writeNumber(convertToFloat(object));
}
}
示例8: getJsonFromWrapperFloatArray
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
public static void getJsonFromWrapperFloatArray(JsonGenerator jg, Float[] array, String pf)
throws JsonGenerationException, IOException {
jg.writeStartArray();
for (Float obj : array) {
jg.writeNumber(obj.floatValue());
}
jg.writeEndArray();
}
示例9: getJsonFromWrapperIntArray
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
public static void getJsonFromWrapperIntArray(JsonGenerator jg, Integer[] array, String pf)
throws JsonGenerationException, IOException {
jg.writeStartArray();
for (Integer obj : array) {
jg.writeNumber(obj.intValue());
}
jg.writeEndArray();
}
示例10: getJsonFromPrimitiveLongArray
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
public static void getJsonFromPrimitiveLongArray(JsonGenerator jg, long[] array, String pf)
throws JsonGenerationException, IOException {
jg.writeStartArray();
for (long obj : array) {
jg.writeNumber(obj);
}
jg.writeEndArray();
}
示例11: serialize
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(JsonGenerator generator) throws IOException {
generator.writeNumber(getCode());
generator.writeStartObject();
if (this.message != null) {
generator.writeStringField("message", this.message);
}
generator.writeEndObject();
generator.writeString(this.reason);
}
示例12: serialize
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(JsonGenerator generator) throws IOException {
generator.writeNumber(getCode());
generator.writeNumber(this.requestId);
generator.writeStartObject();
if (this.discloseCaller) {
generator.writeBooleanField("disclose_caller", this.discloseCaller);
}
generator.writeEndObject();
generator.writeString(this.procedure);
}
示例13: serialize
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(OFPort port, JsonGenerator jGen,
SerializerProvider serializer)
throws IOException, JsonProcessingException {
jGen.writeNumber(port.getPortNumber());
}
示例14: serialize
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(Date value, JsonGenerator jgen, SerializerProvider provider)
throws IOException, JsonProcessingException {
jgen.writeNumber(value.getTime());
}
示例15: serialize
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(final JobDataFragmentWrapper data, JsonGenerator generator, SerializerProvider provider)
throws IOException {
try (TimedBlock b = time("serialize job results VV -> JSON")) {
/**
* Example output:
*
* {
* "returnedRowCount" : 5,
* "columns": [
* {
* "name": "colBit",
* "type": "BOOLEAN",
* "index": 0,
* "status": null
* },
* {
* "name": "colTinyInt",
* "type": "INTEGER",
* "index": 1,
* "status": null
* }
* ],
* "rows" : [
* ... one object for each row written by {@link DACJobResultsSerializer} ...
* ... See {@link DACJobResultsSerializer} for details of format ...
* ]
* }
*
*/
//final RecordBatches recordBatches = data.recordBatches;
generator.writeStartObject();
generator.writeFieldName("returnedRowCount");
generator.writeNumber(data.getReturnedRowCount());
generator.writeFieldName("columns");
generator.writeStartArray();
for (Column c : data.getColumns()) {
generator.writeObject(c);
}
generator.writeEndArray();
generator.writeFieldName("rows");
generator.writeStartArray();
SerializationContextImpl context = new SerializationContextImpl(data.getJobId().getId());
DACJobResultsSerializer jsonWriter =
new DACJobResultsSerializer(generator, context, Integer.getInteger(MAX_CELL_SIZE_KEY, 100));
jsonWriter.setup();
int currentRowInWriting = data.offsetInJobResults; // row number in complete job results
for(RecordBatchHolder batchHolder : data.delegate.getRecordBatches()) {
final EventBasedRecordWriter recordWriter =
new EventBasedRecordWriter(batchHolder.getData().getContainer(), jsonWriter);
for (int i = batchHolder.getStart(); i < batchHolder.getEnd(); i++) {
context.setRowNum(currentRowInWriting++);
recordWriter.writeOneRecord(i);
}
}
generator.writeEndArray();
generator.writeEndObject();
}
}