當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonWriter.value方法代碼示例

本文整理匯總了Java中com.google.gson.stream.JsonWriter.value方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonWriter.value方法的具體用法?Java JsonWriter.value怎麽用?Java JsonWriter.value使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.gson.stream.JsonWriter的用法示例。


在下文中一共展示了JsonWriter.value方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: writePrimitiveOrItsBox

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
public static void writePrimitiveOrItsBox(JsonWriter writer, Class<?> type, Object value) throws IOException {
    if (type == void.class || type == Void.class) {
        writer.value("\"\"");
    } else if (type == boolean.class || type == Boolean.class) {
        writer.value(((Boolean) value).booleanValue());
    } else if (type == byte.class || type == Byte.class) {
        writer.value(((Byte) value).byteValue());
    } else if (type == short.class || type == Short.class) {
        writer.value(((Short) value).shortValue());
    } else if (type == int.class || type == Integer.class) {
        writer.value(((Integer) value).intValue());
    } else if (type == long.class || type == Long.class) {
        writer.value(((Long) value).longValue());
    } else if (type == char.class || type == Character.class) {
        writer.value((Character) value);
    } else if (type == float.class || type == Float.class) {
        writer.value(((Float) value).floatValue());
    } else if (type == double.class || type == Double.class) {
        writer.value(((Double) value).doubleValue());
    } else {
        throw new IllegalStateException();
    }
}
 
開發者ID:LightSun,項目名稱:data-mediator,代碼行數:24,代碼來源:SupportUtils.java

示例2: write

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
@Override
public void write(JsonWriter out, Binary value) throws IOException {
  if (out instanceof BsonWriter) {
    BINARY_ADAPTER.write(out, value.value());
  } else {
    out.value(value.toString());
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:9,代碼來源:TypeAdapters.java

示例3: write

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
@Override
public void write(JsonWriter writer, File value) throws IOException {
    if (value == null) {
        writer.nullValue();
        return;
    }
    writer.value(value.getAbsolutePath());
}
 
開發者ID:VISNode,項目名稱:VISNode,代碼行數:9,代碼來源:FileAdapter.java

示例4: write

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
public synchronized void write(JsonWriter out, Date value) throws IOException {
    if (value == null) {
        out.nullValue();
    } else {
        out.value(this.enUsFormat.format(value));
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:8,代碼來源:DateTypeAdapter.java

示例5: write

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
public void write(JsonWriter out, T value) throws IOException {
    out.beginObject();
    out.name("class");
    out.value(value.getClass().getName());
    out.name("value");
    delegate.write(out, value);
    out.endObject();
}
 
開發者ID:sap-nocops,項目名稱:Jerkoff,代碼行數:9,代碼來源:ObjectTypeAdapterFactory.java

示例6: write

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
@Override
public void write(JsonWriter out, LocalDate date) throws IOException {
  if (date == null) {
    out.nullValue();
  } else {
    out.value(formatter.print(date));
  }
}
 
開發者ID:ARMmbed,項目名稱:mbed-cloud-sdk-java,代碼行數:9,代碼來源:ApiClient.java

示例7: write

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
@Override
public void write(JsonWriter out, Instant value) throws IOException {
  if (value!=null) {
    out.value(ISO_FORMATTER.format(value));
  } else {
    out.nullValue();
  }
}
 
開發者ID:rockscript,項目名稱:rockscript,代碼行數:9,代碼來源:Engine.java

示例8: write

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
@Override public synchronized void write(JsonWriter out, Date value) throws IOException {
  if (value == null) {
    out.nullValue();
    return;
  }
  String dateFormatAsString = enUsFormat.format(value);
  out.value(dateFormatAsString);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:9,代碼來源:DateTypeAdapter.java

示例9: write

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
public void write(JsonWriter out, StringBuilder value) throws IOException {
    out.value(value == null ? null : value.toString());
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:4,代碼來源:TypeAdapters.java

示例10: processCosts

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
private static void processCosts(Connection connection, JsonWriter writer)
    throws IOException, SQLException {
  writer.name("costs").beginObject();

  PreparedStatement stmt = connection.prepareStatement(
      "select year, type, sum(cost) from "
      + "(SELECT c.cost, YEAR(DATEADD('SECOND', e.start/ 1000 , DATE '1970-01-01')) as year, "
      + "e.type FROM ENCOUNTER e, CLAIM c where e.id = c.encounter_id) group by year, type "
      + "order by year asc");
  ResultSet rs = stmt.executeQuery();

  Table<Integer, String, BigDecimal> table = HashBasedTable.create();

  int firstYear = 0;
  int lastYear = 0;

  while (rs.next()) {
    int year = rs.getInt(1);
    String type = rs.getString(2);
    BigDecimal total = rs.getBigDecimal(3);

    if (firstYear == 0) {
      firstYear = year;
    }
    lastYear = year;

    table.put(year, type, total);
  }

  writer.name("first_year").value(firstYear);

  for (String encType : table.columnKeySet()) {
    writer.name(encType).beginArray();

    for (int y = firstYear; y <= lastYear; y++) {
      BigDecimal count = table.get(y, encType);
      if (count == null) {
        count = BigDecimal.ZERO;
      }
      writer.value(count);
    }
    writer.endArray(); // encType
  }

  writer.endObject(); // costs
}
 
開發者ID:synthetichealth,項目名稱:synthea_java,代碼行數:47,代碼來源:ReportExporter.java

示例11: write

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
@Override
public void write(JsonWriter out, Number value) throws IOException {
  out.value(value);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:5,代碼來源:TypeAdapters.java

示例12: write

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
@Override
public void write(JsonWriter out, UserId value) throws IOException {
    out.value(value.toString());
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:5,代碼來源:UserIdTypeAdapter.java

示例13: write

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
@Override public void write(JsonWriter out, Boolean value) throws IOException {
  out.value(value == null ? "null" : value.toString());
}
 
開發者ID:odoo-mobile-intern,項目名稱:odoo-work,代碼行數:4,代碼來源:TypeAdapters.java

示例14: write

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
@Override
public synchronized void write(JsonWriter out, java.sql.Date value) throws IOException {
  out.value(value == null ? null : format.format(value));
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:5,代碼來源:SqlDateTypeAdapter.java


注:本文中的com.google.gson.stream.JsonWriter.value方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。