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


Java JsonElement.getAsLong方法代码示例

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


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

示例1: deserialize

import com.google.gson.JsonElement; //导入方法依赖的package包/类
@Override
public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
    try {
        return json == null ? null : new Date(json.getAsLong());

    } catch (NumberFormatException e) {
        CrashlyticsWrapper.log(e);
        e.printStackTrace();

        return deserialize12HourDateFormatString(json.getAsString());
    }
}
 
开发者ID:hypertrack,项目名称:hypertrack-live-android,代码行数:13,代码来源:DateDeserializer.java

示例2: deserialize

import com.google.gson.JsonElement; //导入方法依赖的package包/类
@Override
public Date deserialize(JsonElement element, Type arg1,
                        JsonDeserializationContext arg2) throws JsonParseException {
    Long timestamp = element.getAsLong();
    Date date = new Date(timestamp);
    return date;
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:8,代码来源:MonitorDataService.java

示例3: getLong

import com.google.gson.JsonElement; //导入方法依赖的package包/类
/**
 * 
 * @param path
 * @return
 */
public Long getLong(String path, Long defaultVal) {
	JsonElement jsonElt = getLastJsonEltInPath(path);

	if (jsonElt == null || jsonElt.isJsonNull()) {
		return defaultVal;
	} else {
		return jsonElt.getAsLong();
	}
}
 
开发者ID:coffee-to-code,项目名称:EasyJson,代码行数:15,代码来源:EasyJson.java

示例4: deserialize

import com.google.gson.JsonElement; //导入方法依赖的package包/类
@Override
public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
    try {
        return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse(json.getAsString());
    } catch (ParseException e) {
        try {
            return new Date(json.getAsLong());
        } catch (RuntimeException e2) {
            Logger.warn("Failed to parse date " + json.getAsString());
        }
    }
    return null;
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:14,代码来源:JsonDeserializer.java

示例5: getDataPoint

import com.google.gson.JsonElement; //导入方法依赖的package包/类
@Override
public DataPoint getDataPoint(long timestamp, JsonElement json)
{
	long value = 0L;
	if (!json.isJsonNull())
		value = json.getAsLong();
	return new LongDataPoint(timestamp, value);
}
 
开发者ID:quqiangsheng,项目名称:abhot,代码行数:9,代码来源:LongDataPointFactoryImpl.java

示例6: deserialize

import com.google.gson.JsonElement; //导入方法依赖的package包/类
public Calendar deserialize(JsonElement json, Type typeOfT,
		JsonDeserializationContext context) throws JsonParseException {
	long timestamp = json.getAsLong();
	Calendar calendar = Calendar.getInstance();
	calendar.setTimeInMillis(timestamp);
	return calendar;
}
 
开发者ID:BotMill,项目名称:botmill-core,代码行数:8,代码来源:CalendarFromTimestampJsonDeserializer.java

示例7: optLong

import com.google.gson.JsonElement; //导入方法依赖的package包/类
public static long optLong(JsonArray array, int index, long fallback){
    JsonElement opt = opt(array, index);
    return opt == null ? fallback : opt.getAsLong();
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:5,代码来源:AbsAdapter.java

示例8: fromJson

import com.google.gson.JsonElement; //导入方法依赖的package包/类
@Override
public Long fromJson(final JsonElement json)
{
    return json.getAsLong();
}
 
开发者ID:Leviathan-Studio,项目名称:MineIDE,代码行数:6,代码来源:DataTypeList.java

示例9: LongValue

import com.google.gson.JsonElement; //导入方法依赖的package包/类
protected LongValue(final JsonElement v, final boolean deprecated, final String encryptionProfile)
{
    super(deprecated, encryptionProfile);
    this.value = v.getAsLong();
}
 
开发者ID:ConfigHubPub,项目名称:JavaAPI,代码行数:6,代码来源:Properties.java

示例10: deserialize

import com.google.gson.JsonElement; //导入方法依赖的package包/类
@Override
public Date deserialize(JsonElement json, Type typeOfT,
                        JsonDeserializationContext context) throws JsonParseException {
    return json == null ? null : new Date(json.getAsLong());
}
 
开发者ID:AmeliaPessoa,项目名称:DBPA,代码行数:6,代码来源:CouchbaseLite.java

示例11: getAsLong

import com.google.gson.JsonElement; //导入方法依赖的package包/类
public static Long getAsLong(JsonElement element) {
  return isNull(element) ? null : element.getAsLong();
}
 
开发者ID:11590692,项目名称:Wechat-Group,代码行数:4,代码来源:GsonHelper.java

示例12: getColumns

import com.google.gson.JsonElement; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public List<Column> getColumns(ITuple input) {
	try {
		String jsonString = input.getString(0);
		JsonObject jsonObject = parser.parse(jsonString).getAsJsonObject();
        List<Column> columns = new ArrayList<Column>();
        for(Column column : schemaColumns) {
            String columnName = column.getColumnName();
			JsonElement elem = jsonObject.get(columnName);
			if (elem==null) continue;
            Integer columnSqlType = column.getSqlType();
            switch (columnSqlType) {
			case Types.VARCHAR:
                String strValue = elem.getAsString();
                columns.add(new Column(columnName, strValue, columnSqlType));
				break;
			case Types.FLOAT:
                Float floatValue = elem.getAsFloat();
                columns.add(new Column(columnName, floatValue, columnSqlType));
				break;
			case Types.DOUBLE:
                Double doubleValue = elem.getAsDouble();
                columns.add(new Column(columnName, doubleValue, columnSqlType));
				break;
			case Types.DATE:
                Date dateValue = new Date(FMT_DATE.parseDateTime(elem.getAsString()).toDate().getTime());
                columns.add(new Column(columnName, dateValue, columnSqlType));
				break;
			case Types.TIMESTAMP:
                Timestamp timeValue = new Timestamp(elem.getAsLong());
                columns.add(new Column(columnName, timeValue, columnSqlType));
				break;
			case Types.SMALLINT:
                Short shortValue = elem.getAsShort();
                columns.add(new Column(columnName, shortValue, columnSqlType));
				break;
			case Types.INTEGER:
                Integer intValue = elem.getAsInt();
                columns.add(new Column(columnName, intValue, columnSqlType));
				break;
			case Types.BIGINT:
                Long longValue = elem.getAsLong();
                columns.add(new Column(columnName, longValue, columnSqlType));
				break;
			default:
                throw new RuntimeException("Unsupported java type in tuple " + Util.getJavaType(columnSqlType));
			}
        }
        return columns;
	} catch(Exception err) {
		throw new RuntimeException("JSON parsing error", err);
	}
}
 
开发者ID:neur0nus,项目名称:storm-clickhouse,代码行数:55,代码来源:JsonJdbcMapper.java

示例13: getLongOrDefaultValue

import com.google.gson.JsonElement; //导入方法依赖的package包/类
static Long getLongOrDefaultValue(JsonElement jsonElement, Long defaultValue)
{
    return jsonElement != null && !jsonElement.isJsonNull() ? jsonElement.getAsLong() : defaultValue;
}
 
开发者ID:riversun,项目名称:slacklet,代码行数:5,代码来源:GsonHelper.java


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