當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。