本文整理汇总了Java中com.google.gson.stream.JsonWriter.endArray方法的典型用法代码示例。如果您正苦于以下问题:Java JsonWriter.endArray方法的具体用法?Java JsonWriter.endArray怎么用?Java JsonWriter.endArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gson.stream.JsonWriter
的用法示例。
在下文中一共展示了JsonWriter.endArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void write(JsonWriter writer, Car3 car) throws IOException {
writer.beginObject();
writer.name("mark").value(car.getMark());
writer.name("model").value(car.getModel());
writer.name("type").value(car.getType());
writer.name("maker").value(car.getMaker());
double costIncludingVAT = car.getCost() + 0.21 * car.getCost();// Add 21% VAT
writer.name("cost").value(costIncludingVAT);
writer.name("colors");
writer.beginArray();
for (String color : car.getColors()) {
writer.value(color);
}
writer.endArray();
writer.endObject();
}
示例2: saveToWriter
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
public static void saveToWriter(Collection<? extends Record> records, Writer writer) throws IOException {
JsonWriter jsonWriter = new JsonWriter(writer);
jsonWriter.beginArray();
for (Record record : records) {
jsonWriter.beginObject();
jsonWriter.name(ALGORITHM_ID).value(record.getAlgorithmId());
jsonWriter.name(DATASET_ID).value(record.getDatasetId());
jsonWriter.name(MEASUREMENT_METHOD).value(record.getMeasurementMethod());
jsonWriter.name(MEASUREMENT_AUTHOR).value(record.getMeasurementAuthor());
jsonWriter.name(MEASUREMENT_TIME).value(record.getMeasurementTime().toString());
jsonWriter.name(CPU_MODEL_NAME).value(record.getCpuModelName());
jsonWriter.name(JAVA_RUNTIME_VERSION).value(record.getJavaRuntimeVersion());
jsonWriter.name(MEASUREMENTS).beginArray();
for (double measurement : record.getMeasurements()) {
jsonWriter.value(measurement);
}
jsonWriter.endArray();
jsonWriter.name(COMMENT).value(record.getComment());
jsonWriter.endObject();
}
jsonWriter.endArray();
}
示例3: write
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void write(JsonWriter out, List<Car3> value) throws IOException {
out.beginArray();
for(Car3 car3 : value){
mAdapter.write(out, car3);
}
out.endArray();
}
示例4: write
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
public void write(JsonWriter out, Collection<E> collection) throws IOException {
if (collection == null) {
out.nullValue();
return;
}
out.beginArray();
for (E element : collection) {
elementTypeAdapter.write(out, element);
}
out.endArray();
}
示例5: 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);
}
}
示例6: write
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
public void write(JsonWriter out, BitSet src) throws IOException {
if (src == null) {
out.nullValue();
return;
}
out.beginArray();
for (int i = 0; i < src.length(); i++) {
int value = (src.get(i)) ? 1 : 0;
out.value(value);
}
out.endArray();
}
示例7: serialize
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void serialize(JsonWriter writer) throws IOException {
writer.beginArray();
for(String tag : tags) {
writer.value(tag);
}
writer.endArray();
}
示例8: serialize
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void serialize(JsonWriter writer) throws IOException {
writer.beginArray();
for(DimensionType dimension : dimensions) {
writer.value(dimension.getName());
}
writer.endArray();
}
示例9: serialize
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void serialize(JsonWriter writer) throws IOException {
writer.beginArray();
for(Bound bound : bounds) {
writer.beginArray();
writer.value(bound.getMin());
writer.value(bound.getMax());
writer.endArray();
}
writer.endArray();
}
示例10: write
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
public void write(JsonWriter out, Collection<E> collection) throws IOException {
if (collection == null) {
out.nullValue();
return;
}
out.beginArray();
for (E element : collection) {
this.elementTypeAdapter.write(out, element);
}
out.endArray();
}
示例11: write
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
@Override
public void write(JsonWriter out, SemanticVersion version) throws IOException {
out.beginArray();
out.value(version.major());
out.value(version.minor());
if(version.patch() != 0) out.value(version.patch());
out.endArray();
}
示例12: 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);
}
}
示例13: write
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
public void write(JsonWriter out, Object array) throws IOException {
if (array == null) {
out.nullValue();
return;
}
out.beginArray();
int length = Array.getLength(array);
for (int i = 0; i < length; i++) {
this.componentTypeAdapter.write(out, Array.get(array, i));
}
out.endArray();
}
示例14: write
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
public void write(JsonWriter out, BitSet src) throws IOException {
if (src == null) {
out.nullValue();
return;
}
out.beginArray();
for (int i = 0; i < src.length(); i++) {
out.value((long) (src.get(i) ? 1 : 0));
}
out.endArray();
}
示例15: processOutcomes
import com.google.gson.stream.JsonWriter; //导入方法依赖的package包/类
private static void processOutcomes(Connection connection, JsonWriter writer)
throws IOException, SQLException {
PreparedStatement stmt = connection.prepareStatement(
"select year, MIN(qol) minimum, MAX(qol) maximum, "
+ "AVG(qol) average, STDDEV_POP(qol) stddev, COUNT(qol) num "
+ "from quality_of_life group by year order by year asc");
// ASSUMPTION - there should never be a gap in years
ResultSet rs = stmt.executeQuery();
int firstYear = 0;
// initial capacity is 80 - think 50 past 30 future?
List<Double> minimums = new ArrayList<Double>(80);
List<Double> maximums = new ArrayList<Double>(80);
List<Double> averages = new ArrayList<Double>(80);
List<Double> stddevs = new ArrayList<Double>(80);
List<Integer> counts = new ArrayList<Integer>(80);
while (rs.next()) {
int year = rs.getInt(1);
if (firstYear == 0) {
firstYear = year;
}
double minimum = rs.getDouble(2);
double maximum = rs.getDouble(3);
double average = rs.getDouble(4);
double stddev = rs.getDouble(5);
int count = rs.getInt(6);
minimums.add(minimum);
maximums.add(maximum);
averages.add(average);
stddevs.add(stddev);
counts.add(count);
}
writer.name("quality_of_life").beginObject();
writer.name("first_year").value(firstYear);
writer.name("minimums").beginArray();
for (double min : minimums) {
writer.value(min);
}
writer.endArray();
writer.name("maximums").beginArray();
for (double max : maximums) {
writer.value(max);
}
writer.endArray();
writer.name("averages").beginArray();
for (double avg : averages) {
writer.value(avg);
}
writer.endArray();
writer.name("stddevs").beginArray();
for (double stdev : stddevs) {
writer.value(stdev);
}
writer.endArray();
writer.name("counts").beginArray();
for (int c : counts) {
writer.value(c);
}
writer.endArray();
writer.endObject(); // quality_of_life
}