本文整理汇总了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();
}
示例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();
}
示例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: 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();
}
示例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();
}
示例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();
}
示例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();
}
}
示例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();
}
示例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();
}
}
}
示例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();
}
示例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();
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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);
}
}