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


Java JsonWriter.name方法代码示例

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


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

示例1: writeJson

import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void writeJson(JsonWriter writer) throws IOException {
	writer.name(getKey());
	writer.beginObject();
	for (Map.Entry<String, String> jsonPair : _value.entrySet()) {
		writer.name(jsonPair.getKey()).value(jsonPair.getValue());
	}
	writer.endObject();
}
 
开发者ID:Chazmondo,项目名称:RankVouchers,代码行数:10,代码来源:TextualComponent.java

示例2: write

import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void write(JsonWriter out, Location value) throws IOException {
    out.beginObject();
    out.name(WORLD_KEY);
    out.value(value.getWorld().getUID().toString());
    out.name(X_KEY);
    out.value(value.getX());
    out.name(Y_KEY);
    out.value(value.getY());
    out.name(Z_KEY);
    out.value(value.getZ());
    out.name(PITCH);
    out.value(value.getPitch());
    out.name(YAW);
    out.value(value.getYaw());
    out.endObject();
}
 
开发者ID:Twister915,项目名称:pl,代码行数:18,代码来源:LocationTypeAdapter.java

示例3: write

import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void write(JsonWriter out, ItemStack value) throws IOException {
    if (value != null) {
        out.beginObject();
        out.name("id").value(value.getTypeId());
        if (value.getDurability() > 0)
            out.name("damage").value(value.getDurability());
        if (value.getAmount() > 0)
            out.name("amount").value(value.getAmount());
        if (value.getItemMeta() != null) {
            out.name("meta");
            metaAdapter.write(out, value.getItemMeta());
        }
        out.endObject();
    } else {
        out.nullValue();
    }
}
 
开发者ID:EntryPointKR,项目名称:MCLibrary,代码行数:19,代码来源:ItemStackTypeAdapter.java

示例4: write

import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
public void write(JsonWriter out, Calendar value) throws IOException {
    if (value == null) {
        out.nullValue();
        return;
    }
    out.beginObject();
    out.name("year");
    out.value((long) value.get(1));
    out.name("month");
    out.value((long) value.get(2));
    out.name(DAY_OF_MONTH);
    out.value((long) value.get(5));
    out.name(HOUR_OF_DAY);
    out.value((long) value.get(11));
    out.name("minute");
    out.value((long) value.get(12));
    out.name(SECOND);
    out.value((long) value.get(13));
    out.endObject();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:TypeAdapters.java

示例5: encode

import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
private String encode(Object instance)
        throws IOException {
    StringWriter stringWriter = new StringWriter();
    JsonWriter writer = new JsonWriter(stringWriter);

    try {
        Class<?> type = instance.getClass();

        writer.beginObject();
        writer.name(type.getName());
        gson.toJson(instance, type, writer);
        writer.endObject();

        return stringWriter.toString();
    } finally {
        writer.close();
    }
}
 
开发者ID:Zhuinden,项目名称:simple-stack,代码行数:19,代码来源:GsonParceler.java

示例6: write

import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void write(JsonWriter out,  GsonProperty property, Object value) throws IOException {
    final Class<?> simpleType = property.getType();
    out.beginObject();
    if(value != null) {
        final SparseArray sa = (SparseArray) value;
        if(simpleType.isPrimitive() || isBoxedClass(simpleType)){
            for (int size = sa.size(), i = size - 1; i >= 0; i--) {
                out.name(sa.keyAt(i) + "");
                writePrimitiveOrItsBox(out, simpleType, sa.valueAt(i));
            }
        }else {
            TypeAdapter adapter = getTypeAdapter(simpleType);
            for (int size = sa.size(), i = size - 1; i >= 0; i--) {
                out.name(sa.keyAt(i) + "");
                adapter.write(out, sa.valueAt(i));
            }
        }
    }
    out.endObject();
}
 
开发者ID:LightSun,项目名称:data-mediator,代码行数:22,代码来源:TypeHandler.java

示例7: write

import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
public void write(JsonWriter out, T value) throws IOException {
    if (value == null) {
        out.nullValue();
        return;
    }
    out.beginObject();
    try {
        for (BoundField boundField : this.boundFields.values()) {
            if (boundField.serialized) {
                out.name(boundField.name);
                boundField.write(out, value);
            }
        }
        out.endObject();
    } catch (IllegalAccessException e) {
        throw new AssertionError();
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:19,代码来源:ReflectiveTypeAdapterFactory.java

示例8: write

import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void write(JsonWriter out, GUISignature value) throws IOException {
    if (value != null) {
        Map<Integer, Integer> hashCodeMap = new HashMap<>();
        Map<Integer, Object> contents = new HashMap<>();
        Map<Integer, ItemStack> itemMap = value.getContents();
        for (Map.Entry<Integer, ItemStack> entry : itemMap.entrySet()) {
            contents.put(entry.getKey(), value(contents, entry.getValue(), hashCodeMap));
        }

        out.beginObject();
        out.name("type").value(value.getType().name());
        out.name("title").value(value.getTitle());
        out.name("size").value(value.getSize());
        out.name("data");
        mapAdapter.write(out, contents);
        out.name("handlerIndexes");
        collectionAdapter.write(out, value.getHandlerIndexes());
        out.endObject();
    } else {
        out.nullValue();
    }
}
 
开发者ID:EntryPointKR,项目名称:MCLibrary,代码行数:24,代码来源:GUISignatureTypeAdapter.java

示例9: write

import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void write(JsonWriter out, Calendar value) throws IOException {
  if (value == null) {
    out.nullValue();
    return;
  }
  out.beginObject();
  out.name(YEAR);
  out.value(value.get(Calendar.YEAR));
  out.name(MONTH);
  out.value(value.get(Calendar.MONTH));
  out.name(DAY_OF_MONTH);
  out.value(value.get(Calendar.DAY_OF_MONTH));
  out.name(HOUR_OF_DAY);
  out.value(value.get(Calendar.HOUR_OF_DAY));
  out.name(MINUTE);
  out.value(value.get(Calendar.MINUTE));
  out.name(SECOND);
  out.value(value.get(Calendar.SECOND));
  out.endObject();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:TypeAdapters.java

示例10: writeJson

import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
public void writeJson(JsonWriter jsonWriter) throws IOException {
	jsonWriter.beginObject();
	jsonWriter.name("max");
	max.writeJson(jsonWriter);
	jsonWriter.name("min");
	min.writeJson(jsonWriter);
	jsonWriter.endObject();
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:9,代码来源:Bound.java

示例11: write

import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void write(
    final JsonWriter out,
    final T value
) throws IOException {

  // support null objects
  if (value == null) {
    out.nullValue();
    return;
  }

  // assert begin of object
  out.beginObject();

  // get discriminator
  Object discriminator = fieldAccess.get(value, DISCRIMINATOR_FIELD_NAME);

  // write discriminator
  out.name(DISCRIMINATOR_FIELD_NAME);
  ((TypeAdapter<Object>) discriminatorTypeAdapter).write(out, discriminator);

  // get corresponding union field info
  UnionMemberInfo unionMemberInfo = memberInfoMap.get(discriminator.toString());

  // write field
  out.name(unionMemberInfo.fieldName);
  ((TypeAdapter<Object>) unionMemberInfo.typeAdapter).write(
      out,
      fieldAccess.get(value, unionMemberInfo.fieldName)
  );

  // assert end of object
  out.endObject();
}
 
开发者ID:aguther,项目名称:dds-examples,代码行数:36,代码来源:UnionTypeAdapterFactory.java

示例12: testWr

import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Test
public void testWr() {
    try {
        Writer wr = new StringWriter();
        JsonWriter out = new JsonWriter(wr);
        out.beginObject();
        out.name("class");
        out.value(this.getClass().getName());
        out.endObject();
        out.close();
        LOG.info("json: " + wr.toString());
    } catch (Exception e) {
        LOG.error(e);
    }
}
 
开发者ID:sap-nocops,项目名称:Jerkoff,代码行数:16,代码来源:GsonTest.java

示例13: serialize

import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void serialize(JsonWriter writer) throws IOException {
    writer.beginObject();

    writer.name("value");
    writer.value(getAsString());

    writer.endObject();
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:10,代码来源:Setting.java

示例14: serialize

import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void serialize(JsonWriter writer) throws IOException {
    writer.beginObject();

    writer.name("bind");
    if(bind != null)
        writer.value(bind.getKeyCode());
    else
        writer.value(-1);

    writer.endObject();
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:13,代码来源:CommandStub.java

示例15: serialize

import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void serialize(JsonWriter writer) throws IOException {
    writer.beginObject();

    writer.name("enabled");
    writer.value(enabled);

    writer.name("keyword");
    writer.value(keyword);

    writer.name("type");
    writer.value(type.name());

    writer.name("trigger");
    writer.value(trigger.name());

    writer.name("delay");
    writer.value(getDelay());

    writer.name("messages");
    writer.beginArray();
    for(String msg : messages) {
        writer.value(msg);
    }
    writer.endArray();

    writer.endObject();
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:29,代码来源:SpamEntry.java


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