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


Java JsonGenerator.writeObject方法代码示例

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


在下文中一共展示了JsonGenerator.writeObject方法的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);
	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

示例2: 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();
	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,代码行数:22,代码来源:ResultMessage.java

示例3: serialize

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(Face value, JsonGenerator jgen, SerializerProvider provider)
		throws IOException {
	jgen.writeStartObject();
	jgen.writeFieldId(1);
	jgen.writeObject(value.sai);
	jgen.writeFieldId(5);
	jgen.writeNumber(value.getTs().getTime()/1000);
	jgen.writeFieldId(6);
	jgen.writeNumber(value.getLifetime());
	jgen.writeFieldId(12);
	jgen.writeBinary(value.getNonce());
	jgen.writeFieldId(7);
	jgen.writeNumber(value.macMethod.encoding);
	jgen.writeEndObject();
}
 
开发者ID:beduino-project,项目名称:dcaf-java,代码行数:17,代码来源:Face.java

示例4: serialize

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(Enum value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
    if (value == null) {
        gen.writeNull();
        return;
    }
    try {
        PropertyDescriptor pd = getPropertyDescriptor(value, prop);
        if (pd == null || pd.getReadMethod() == null) {
            gen.writeString(value.name());
            return;
        }
        Method m = pd.getReadMethod();
        m.setAccessible(true);
        gen.writeObject(m.invoke(value));
    } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:thlcly,项目名称:Dude,代码行数:20,代码来源:CustomEnumSerializer.java

示例5: serialize

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
    public void serialize(Wrapper<?> value, JsonGenerator gen, SerializerProvider provider) throws IOException {
        // TODO: maybe find a cleaner way to do this
        if(Vector.class.isAssignableFrom(value.getWrappedClass())) {
            // value is a vector, just write the coordinates
            gen.writeObject(((Vector) value.getWrapped()).toArray());
            return;
        }
        gen.writeStartObject();
        gen.writeStringField("class", value.getWrappedClass().getSimpleName());
        gen.writeNumberField("id", value.getWrappedId());
        value.getValues().forEach((name, obj) -> {
            try {
                gen.writeObjectField(name, obj);
            } catch (IOException e) {
                e.printStackTrace();
            }
        });
//        for(Property p : value.getProperties()) {
//            gen.writeObjectField(p.getName(), p);
//        }
        gen.writeEndObject();
    }
 
开发者ID:etomica,项目名称:etomica,代码行数:24,代码来源:WrapperSerializer.java

示例6: serialize

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(OvsdbMap map, JsonGenerator generator,
                      SerializerProvider provider)
        throws IOException, JsonProcessingException {
    generator.writeStartArray();
    generator.writeString("map");
    generator.writeStartArray();
    Map javaMap = map.map();
    for (Object key : javaMap.keySet()) {
        generator.writeStartArray();
        generator.writeObject(key);
        generator.writeObject(javaMap.get(key));
        generator.writeEndArray();
    }
    generator.writeEndArray();
    generator.writeEndArray();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:OvsdbMapSerializer.java

示例7: serialize

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(Object value, JsonGenerator gen,
   SerializerProvider serializers) throws IOException,
   JsonProcessingException
{
   if (value instanceof Element)
   {
      Element element = (Element) value;
      String content = element.getTextContent();
      gen.writeString(content);
   }
   else if (value instanceof JAXBElement<?>)
   {
      Object elemValue = ((JAXBElement<?>) value).getValue();
      if (elemValue instanceof Element)
      {
         serialize(((JAXBElement<?>) value).getValue(), gen, serializers);
      }
      else
      {
         gen.writeObject(elemValue);
      }
   }
   else
   {
      gen.writeObject(value);
   }
}
 
开发者ID:dmn-tck,项目名称:tck,代码行数:29,代码来源:ValueSerializer.java

示例8: writeAsArray

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
/**
 * Schrijf object als Array.
 * @param jgen json generator
 * @param nodeName node naam
 * @param waarde node waarde
 * @throws IOException bij schrijf fouten
 */
static void writeAsArray(final JsonGenerator jgen, final String nodeName, final Collection<?> waarde) throws IOException {
    if (waarde != null && !waarde.isEmpty()) {
        jgen.writeFieldName(nodeName);
        jgen.writeStartArray(waarde.size());
        for (final Object huidigObject : waarde) {
            jgen.writeObject(huidigObject);
        }
        jgen.writeEndArray();
    }
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:18,代码来源:JsonUtils.java

示例9: serialize

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(OvsdbSet set, JsonGenerator generator,
                      SerializerProvider provider)
        throws IOException, JsonProcessingException {
    generator.writeStartArray();
    generator.writeString("set");
    generator.writeStartArray();
    Set javaSet = set.set();
    for (Object key : javaSet) {
        generator.writeObject(key);
    }
    generator.writeEndArray();
    generator.writeEndArray();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:15,代码来源:OvsdbSetSerializer.java

示例10: writeObject

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public boolean writeObject(Object obj, JsonGenerator jgen, boolean expand) throws JsonProcessingException, IOException {
  logger.debug("list of maps");
  // convert this 'on the fly' to a datatable
  Collection<?> col = scala.collection.JavaConversions.asJavaCollection((Iterable<?>) obj);
  List<Map<?,?>> tab = new ArrayList<Map<?,?>>();
  for (Object o : col) {
    Map<?, ?> row = scala.collection.JavaConversions.mapAsJavaMap((scala.collection.Map<?, ?>) o);
    tab.add(row);
  }
  TableDisplay t = new TableDisplay(tab,parent);
  jgen.writeObject(t);
  return true;
}
 
开发者ID:twosigma,项目名称:beaker-notebook-archive,代码行数:15,代码来源:ScalaEvaluator.java

示例11: serialize

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(ClaimsHolder holder, JsonGenerator gen, SerializerProvider provider) throws IOException {
    HashMap<Object, Object> safePayload = new HashMap<>();
    for (Map.Entry<String, Object> e : holder.getClaims().entrySet()) {
        switch (e.getKey()) {
            case PublicClaims.AUDIENCE:
                if (e.getValue() instanceof String) {
                    safePayload.put(e.getKey(), e.getValue());
                    break;
                }
                String[] audArray = (String[]) e.getValue();
                if (audArray.length == 1) {
                    safePayload.put(e.getKey(), audArray[0]);
                } else if (audArray.length > 1) {
                    safePayload.put(e.getKey(), audArray);
                }
                break;
            case PublicClaims.EXPIRES_AT:
            case PublicClaims.ISSUED_AT:
            case PublicClaims.NOT_BEFORE:
                safePayload.put(e.getKey(), dateToSeconds((Date) e.getValue()));
                break;
            default:
                if (e.getValue() instanceof Date) {
                    safePayload.put(e.getKey(), dateToSeconds((Date) e.getValue()));
                } else {
                    safePayload.put(e.getKey(), e.getValue());
                }
                break;
        }
    }

    gen.writeObject(safePayload);
}
 
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:35,代码来源:PayloadSerializer.java

示例12: serialize

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(Block value, JsonGenerator gen, SerializerProvider provider) throws IOException {

	Map<String, Object> map = BlockMapper.convert(value);
	map.put(StringConstant.id, Format.ID.blockId(value.getID()));
	gen.writeObject(map);

}
 
开发者ID:EonTechnology,项目名称:server,代码行数:9,代码来源:BlockSerializer.java

示例13: writeObject

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public boolean writeObject(Object obj, JsonGenerator jgen, boolean expand) throws JsonProcessingException, IOException {
  logger.debug("collection");
  // convert this 'on the fly' to an array of objects
  Collection<?> c = (Collection<?>) obj;
  jgen.writeStartArray();
  for(Object o : c) {
    if (!parent.writeObject(o, jgen, false))
      jgen.writeObject(o.toString());
  }
  jgen.writeEndArray();
  return true;
}
 
开发者ID:twosigma,项目名称:beaker-notebook-archive,代码行数:14,代码来源:BasicObjectSerializer.java

示例14: serialize

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(T value,
                      JsonGenerator jgen,
                      SerializerProvider provider)
  throws IOException, JsonProcessingException {

  synchronized (value) {
    jgen.writeStartObject();

    jgen.writeObjectField("type", value.getClass().getSimpleName());

    serialize(value, jgen);

    jgen.writeArrayFieldStart("labels");
    if (value.getLabels() != null) {
      for (String label : value.getLabels())
        jgen.writeObject(label);
    }
    jgen.writeEndArray();

    jgen.writeArrayFieldStart("items");
    if (value.getItems() != null) {
      for (Object obj : value.getItems())
        if (!getObjectSerializer().writeObject(obj, jgen, true))
          jgen.writeObject(obj.toString());
    }
    jgen.writeEndArray();

    jgen.writeObjectField("layout", value.getLayoutManager());

    jgen.writeEndObject();
  }
}
 
开发者ID:twosigma,项目名称:beaker-notebook-archive,代码行数:34,代码来源:BasicOutputContainerSerializer.java

示例15: serialize

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(final Enumeratie value, final JsonGenerator jgen, final SerializerProvider provider) throws IOException {
    jgen.writeObject(value.getId());
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:5,代码来源:EnumSerializer.java


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