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


Java JsonGenerator.writeStartArray方法代码示例

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


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

示例1: serialize

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(ObfuscationLinkState oLinkState, JsonGenerator jGen,
                      SerializerProvider arg2) throws IOException,
                                              JsonProcessingException {
    jGen.writeStartObject();

    jGen.writeStringField("src", oLinkState.getLink().getSrc().toString());
    jGen.writeStringField("dst", oLinkState.getLink().getDst().toString());
    jGen.writeNumberField("srcPort", oLinkState.getLink().getSrcPort().getPortNumber());
    jGen.writeNumberField("dstPort", oLinkState.getLink().getDstPort().getPortNumber());
    
    jGen.writeFieldName("masks");
    jGen.writeStartArray();
    for (long dst: oLinkState.getInstalledMasks().keySet()) {
        jGen.writeStartObject();
    	//jGen.writeStringField("dst", dst.toString());
    	jGen.writeNumberField("observed_entropy", oLinkState.getObservedEntropy(dst));
    	jGen.writeNumberField("unicity_distance", oLinkState.getUnicityDistance(dst));
    	jGen.writeNumberField("flows", oLinkState.getNumberOfMaskUsages(dst));
    	jGen.writeEndObject();
    }
    jGen.writeEndArray();
    
    
    jGen.writeEndObject();
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:27,代码来源:ObfuscationLinkStateJsonSerializer.java

示例2: serialize

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(SubFunction value, JsonGenerator gen, SerializerProvider serializers)
    throws IOException, JsonProcessingException {
    gen.writeStartObject();
    gen.writeFieldName("Fn::Sub");

    if (value.getVariableMap() == null) {
        gen.writeString(value.getStringTemplate());
    } else {
        gen.writeStartArray();
        gen.writeString(value.getStringTemplate());
        serializers.defaultSerializeValue(value.getVariableMap(), gen);
        gen.writeEndArray();
    }

    gen.writeEndObject();
}
 
开发者ID:salesforce,项目名称:cf2pojo,代码行数:18,代码来源:SubFunction.java

示例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);
	}
}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:26,代码来源:InvocationMessage.java

示例4: getJSONStringFromCollection

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
private void getJSONStringFromCollection(JsonGenerator jg, Collection<?> coll, String pf)
    throws JsonGenerationException, IOException {
  jg.writeStartArray();

  for (Object obj : coll) {
    writeValue(jg, obj, pf);
  }
  jg.writeEndArray();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:10,代码来源:PdxToJSON.java

示例5: printRepeatedNull

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
static void printRepeatedNull(List<Integer> values, JsonGenerator gen) throws IOException {
  int numElements = values.size();
  gen.writeStartArray(numElements);
  for (int i = 0; i < numElements; i++) {
    printNull(values.get(i), gen);
  }
  gen.writeEndArray();
}
 
开发者ID:curioswitch,项目名称:curiostack,代码行数:9,代码来源:SerializeSupport.java

示例6: getJsonFromBigIntArray

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
public static void getJsonFromBigIntArray(JsonGenerator jg, BigInteger[] array, String pf)
    throws JsonGenerationException, IOException {
  jg.writeStartArray();
  for (BigInteger obj : array) {
    jg.writeNumber(obj);
  }
  jg.writeEndArray();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:9,代码来源:JsonHelper.java

示例7: serializeActions

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
public void serializeActions(Set<OFActionType> actions, JsonGenerator jGen)
        throws IOException, JsonProcessingException {
    if ( null == actions)
        jGen.writeStringField("actions","null");
    else{
        jGen.writeFieldName("actions");
        jGen.writeStartArray();
        for(OFActionType action : actions){
            jGen.writeString(action.toString());
        }
        jGen.writeEndArray();
    }
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:14,代码来源:IOFSwitchSerializer.java

示例8: printRepeatedBool

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
static void printRepeatedBool(List<Boolean> values, JsonGenerator gen) throws IOException {
  int numElements = values.size();
  gen.writeStartArray(numElements);
  for (int i = 0; i < numElements; i++) {
    printBool(values.get(i), gen);
  }
  gen.writeEndArray();
}
 
开发者ID:curioswitch,项目名称:curiostack,代码行数:9,代码来源:SerializeSupport.java

示例9: serialize

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(PropertyValue value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
  if (value.getLocalizations().size() == 1 && value.getLocalizations().contains(Locale.ROOT)) {
    // Simple property value
    if (value.getValues().size() == 1) {
      jgen.writeString(value.getValues().get(0));
    } else {
      jgen.writeStartArray();
      for (String val : value.getValues()) {
        jgen.writeString(val);
      }
      jgen.writeEndArray();
    }
  } else {
    // Localized property value
    Set<Locale> localizations = value.getLocalizations();
    if (localizations.size() == 1) {
      Locale lang = localizations.iterator().next();
      writeSingleLocalization(jgen, lang, value.getValues(lang));
    } else if (localizations.size() > 1) {
      jgen.writeStartArray();
      for (Locale language : localizations) {
        writeSingleLocalization(jgen, language, value.getValues(language));
      }
      jgen.writeEndArray();
    } else {
      jgen.writeNull();
    }
  }
}
 
开发者ID:dbmdz,项目名称:iiif-apis,代码行数:31,代码来源:PropertyValueSerializer.java

示例10: printRepeatedDouble

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
static void printRepeatedDouble(List<Double> values, JsonGenerator gen) throws IOException {
  int numElements = values.size();
  gen.writeStartArray(numElements);
  for (int i = 0; i < numElements; i++) {
    printDouble(values.get(i), gen);
  }
  gen.writeEndArray();
}
 
开发者ID:curioswitch,项目名称:curiostack,代码行数:9,代码来源:SerializeSupport.java

示例11: doWrite

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void doWrite(ListValue message, JsonGenerator gen) throws IOException {
  List<Value> values = message.getValuesList();
  int numElements = values.size();
  gen.writeStartArray(numElements);
  for (int i = 0; i < numElements; i++) {
    ValueMarshaller.INSTANCE.writeValue(values.get(i), gen);
  }
  gen.writeEndArray();
}
 
开发者ID:curioswitch,项目名称:curiostack,代码行数:11,代码来源:WellKnownTypeMarshaller.java

示例12: printSingleField

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
private void printSingleField(FieldDescriptor field,
                                     Object value,
                                     JsonGenerator generator) throws IOException {
    if (field.isExtension()) {
        // We special-case MessageSet elements for compatibility with proto1.
        if (field.getContainingType().getOptions().getMessageSetWireFormat()
            && (field.getType() == FieldDescriptor.Type.MESSAGE) && (field.isOptional())
            // object equality
            && (field.getExtensionScope() == field.getMessageType())) {
            generator.writeFieldName(field.getMessageType().getFullName());
        } else {
        	// extensions will have '.' in them, while normal fields wont..
        	generator.writeFieldName(field.getFullName());
        }
    } else {
        if (field.getType() == FieldDescriptor.Type.GROUP) {
            // Groups must be serialized with their original capitalization.
            generator.writeFieldName(field.getMessageType().getName());
        } else {
            generator.writeFieldName(field.getName());
        }
    }

    // Done with the name, on to the value
    if (field.isRepeated()) {
        // Repeated field. Print each element.
        generator.writeStartArray();
        for (Iterator<?> iter = ((List<?>) value).iterator(); iter.hasNext();) {
            printFieldValue(field, iter.next(), generator);
        }
        generator.writeEndArray();
    } else {
        printFieldValue(field, value, generator);
    }
}
 
开发者ID:jigsaw-projects,项目名称:jigsaw-payment,代码行数:36,代码来源:JsonJacksonFormat.java

示例13: addIndexedLine

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
public static void addIndexedLine(JsonGenerator jg, String prefix,
    Object element, Integer idx,
    List<Parameter> parameterList) {
    try {
        jg.writeStartArray();
        //prefix
        jg.writeString(prefix);
        //key
        jg.writeString(new StringBuilder().append(getElementName(element).
            orElseThrow(() ->
            {
                return new ElementNameMappingException(element);
            })).
            append("[").
            append(idx).
            append("]").
            toString());
        //value
        jg.writeString(parameterList.stream().
            map((parameter) ->
            {
                return ParameterSerializer.toString(parameter);
            }).
            collect(Collectors.joining("|")));
        jg.writeEndArray();
    } catch (IOException ex) {
        Logger.getLogger(MetadataSerializer.class.getName()).
            log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:nilshoffmann,项目名称:jmzTab-m,代码行数:31,代码来源:Serializers.java

示例14: serialize

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
private byte[] serialize(final List<TypedIncomingData> data) throws Exception {
  final ByteArrayOutputStream output = new ByteArrayOutputStream();
  final JsonGenerator json = JSON.getFactory().createGenerator(output);
  json.writeStartArray();
  for (final TypedIncomingData d : data) {
    json.writeObject(d);
  }
  json.writeEndArray();
  json.close();
  return output.toByteArray();
}
 
开发者ID:OpenTSDB,项目名称:opentsdb-rpc-kafka,代码行数:12,代码来源:TestJSONDeserializer.java

示例15: 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.discloseMe) {
		generator.writeBooleanField("disclose_me", this.discloseMe);
	}
	generator.writeEndObject();

	generator.writeString(this.procedure);

	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);
	}
}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:28,代码来源:CallMessage.java


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