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