本文整理匯總了Java中com.google.gson.stream.JsonWriter.endObject方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonWriter.endObject方法的具體用法?Java JsonWriter.endObject怎麽用?Java JsonWriter.endObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gson.stream.JsonWriter
的用法示例。
在下文中一共展示了JsonWriter.endObject方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: write
import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
@Override public void write(JsonWriter out, T value) throws IOException {
if (value == null) {
out.nullValue();
return;
}
out.beginObject();
try {
for (BoundField boundField : boundFields.values()) {
if (boundField.writeField(value)) {
out.name(boundField.name);
boundField.write(out, value);
}
}
} catch (IllegalAccessException e) {
throw new AssertionError();
}
out.endObject();
}
示例2: 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();
}
示例3: serialize
import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
@Override
public void serialize(JsonWriter writer) throws IOException {
writer.beginObject();
writer.name("messages");
writer.beginArray();
for(MessageEntry entry : messages) {
writer.beginObject();
writer.name(entry.toString());
entry.serialize(writer);
writer.endObject();
}
writer.endArray();
writer.endObject();
}
示例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();
}
示例5: export
import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
public static void export(Generator generator) {
if (generator == null || generator.database == null) {
return;
}
try (Connection connection = generator.database.getConnection()) {
File outDirectory = Exporter.getOutputFolder("statistics", null);
String timeStamp = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(new Date());
Path outFilePath = outDirectory.toPath().resolve("statistics-" + timeStamp + ".json");
JsonWriter writer = new JsonWriter(new FileWriter(outFilePath.toFile()));
writer.setIndent(" ");
writer.beginObject(); // top-level
reportParameters(writer);
processOutcomes(connection, writer);
processAccess(connection, writer);
processCosts(connection, writer);
writer.endObject(); // top-level
writer.close();
} catch (IOException | SQLException e) {
e.printStackTrace();
throw new RuntimeException("error exporting statistics");
}
}
示例6: writeJson
import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
public void writeJson(JsonWriter json) {
try {
json.beginObject();
text.writeJson(json);
json.name("color").value(color.name().toLowerCase());
for (final ChatColor style : styles) {
json.name(stylesToNames.get(style)).value(true);
}
if (clickActionName != null && clickActionData != null) {
json.name("clickEvent")
.beginObject()
.name("action").value(clickActionName)
.name("value").value(clickActionData)
.endObject();
}
if (hoverActionName != null && hoverActionData != null) {
json.name("hoverEvent")
.beginObject()
.name("action").value(hoverActionName)
.name("value");
hoverActionData.writeJson(json);
json.endObject();
}
if (insertionData != null) {
json.name("insertion").value(insertionData);
}
if (translationReplacements.size() > 0 && text != null && TextualComponent.isTranslatableText(text)) {
json.name("with").beginArray();
for (JsonRepresentedObject obj : translationReplacements) {
obj.writeJson(json);
}
json.endArray();
}
json.endObject();
} catch (IOException e) {
Bukkit.getLogger().log(Level.WARNING, "A problem occured during writing of JSON string", e);
}
}
示例7: write
import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
@Override
public void write(final JsonWriter out, final CloudAppConfiguration value) throws IOException {
out.beginObject();
out.name(APP_NAME).value(value.getAppName());
out.name(APP_URL).value(value.getAppURL());
out.name(BOOTSTRAP_SCRIPT).value(value.getBootstrapScript());
out.name(CPU_COUNT).value(value.getCpuCount());
out.name(MEMORY_MB).value(value.getMemoryMB());
out.name(APP_CACHE_ENABLE).value(value.isAppCacheEnable());
out.name(EVENT_TRACE_SAMPLING_COUNT).value(value.getEventTraceSamplingCount());
out.endObject();
}
示例8: 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();
}
示例9: write
import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
@Override
public void write(JsonWriter out, Location location) throws IOException
{
out.beginObject();
out.name("x").value(location == null ? 30000001 : location.getX());
out.name("y").value(location == null ? 30000001 : location.getY());
out.name("z").value(location == null ? 30000001 : location.getZ());
out.name("pitch").value(location == null ? 30000001 : location.getPitch());
out.name("yaw").value(location == null ? 30000001 : location.getYaw());
out.name("world").value((location == null || location.getWorld() == null) ? "" : location.getWorld().getName());
out.endObject();
}
示例10: 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();
}
示例11: 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();
}
示例12: writeJson
import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
public void writeJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.beginObject();
jsonWriter.name("x").value(x);
jsonWriter.name("y").value(y);
jsonWriter.name("z").value(z);
jsonWriter.endObject();
}
示例13: writeJson
import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
public void writeJson(JsonWriter json) {
try {
json.beginObject();
text.writeJson(json);
json.name("color").value(color.name().toLowerCase());
for (final ChatColor style : styles) {
json.name(stylesToNames.get(style)).value(true);
}
if (clickActionName != null && clickActionData != null) {
json.name("clickEvent").beginObject().name("action").value(clickActionName).name("value").value(clickActionData).endObject();
}
if (hoverActionName != null && hoverActionData != null) {
json.name("hoverEvent").beginObject().name("action").value(hoverActionName).name("value");
hoverActionData.writeJson(json);
json.endObject();
}
if (insertionData != null) {
json.name("insertion").value(insertionData);
}
if (translationReplacements.size() > 0 && text != null && TextualComponent.isTranslatableText(text)) {
json.name("with").beginArray();
for (JsonRepresentedObject obj : translationReplacements) {
obj.writeJson(json);
}
json.endArray();
}
json.endObject();
} catch (IOException e) {
Bukkit.getLogger().log(Level.WARNING, "A problem occured during writing of JSON string", e);
}
}
示例14: write
import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
@Override
public void write(JsonWriter out, IStudent value) throws IOException {
GsonTest.log("write");
out.beginObject();
out.name("name").value("heaven7");
out.name("id").value("26");
out.endObject();
}
示例15: writeJson
import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
public void writeJson(JsonWriter json) {
try {
json.beginObject();
text.writeJson(json);
json.name("color").value(color.name().toLowerCase());
for (final ChatColor style : styles) {
json.name(stylesToNames.get(style)).value(true);
}
if (clickActionName != null && clickActionData != null) {
json.name("clickEvent")
.beginObject()
.name("action").value(clickActionName)
.name("value").value(clickActionData)
.endObject();
}
if (hoverActionName != null && hoverActionData != null) {
json.name("hoverEvent")
.beginObject()
.name("action").value(hoverActionName)
.name("value");
hoverActionData.writeJson(json);
json.endObject();
}
if(insertionData != null){
json.name("insertion").value(insertionData);
}
if(translationReplacements.size() > 0 && text != null && TextualComponent.isTranslatableText(text)){
json.name("with").beginArray();
for(JsonRepresentedObject obj : translationReplacements){
obj.writeJson(json);
}
json.endArray();
}
json.endObject();
} catch(IOException e){
Bukkit.getLogger().log(Level.WARNING, "A problem occured during writing of JSON string", e);
}
}