本文整理匯總了Java中com.fasterxml.jackson.core.JsonParser.getValueAsLong方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonParser.getValueAsLong方法的具體用法?Java JsonParser.getValueAsLong怎麽用?Java JsonParser.getValueAsLong使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.fasterxml.jackson.core.JsonParser
的用法示例。
在下文中一共展示了JsonParser.getValueAsLong方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseField
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
protected void parseField(String fieldName, JsonParser parser) throws IOException {
switch (fieldName) {
case "trade_id":
parser.nextToken();
tradeId = parser.getValueAsLong();
break;
case "maker_order_id":
parser.nextToken();
makerOrderId = parser.getValueAsString();
break;
case "taker_order_id":
parser.nextToken();
takerOrderId = parser.getValueAsString();
break;
case "size":
parser.nextToken();
size = new BigDecimal(parser.getValueAsString());
break;
default:
break;
}
}
示例2: readRecord
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
Map<String, Object> readRecord(JsonParser jp) throws IOException {
Map<String, Object> record = new HashMap<>();
String fielName = "";
Object value;
JsonToken token;
while((token = jp.nextToken()) != JsonToken.END_OBJECT) {
if (token == JsonToken.FIELD_NAME) {
fielName = jp.getCurrentName();
} else if (token == JsonToken.VALUE_STRING) {
value = jp.getValueAsString();
record.put(fielName, value);
} else if (token == JsonToken.VALUE_NUMBER_INT) {
value = jp.getValueAsLong();
record.put(fielName, value);
}
}
//System.out.println(record.toString());
return record;
}
示例3: parseField
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public void parseField(SimpleGenericModel<T> instance, String fieldName, JsonParser jsonParser) throws IOException {
if ("date".equals(fieldName)) {
instance.date = getjava_util_Date_type_converter().parse(jsonParser);
} else if ("string".equals(fieldName)) {
instance.string = jsonParser.getValueAsString(null);
} else if ("test_double".equals(fieldName)) {
instance.testDouble = jsonParser.getValueAsDouble();
} else if ("test_double_obj".equals(fieldName)) {
instance.testDoubleObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Double.valueOf(jsonParser.getValueAsDouble());
} else if ("test_float".equals(fieldName)) {
instance.testFloat = (float)jsonParser.getValueAsDouble();
} else if ("test_float_obj".equals(fieldName)) {
instance.testFloatObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : new Float(jsonParser.getValueAsDouble());
} else if ("test_int".equals(fieldName)) {
instance.testInt = jsonParser.getValueAsInt();
} else if ("test_int_obj".equals(fieldName)) {
instance.testIntObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Integer.valueOf(jsonParser.getValueAsInt());
} else if ("test_long".equals(fieldName)) {
instance.testLong = jsonParser.getValueAsLong();
} else if ("test_long_obj".equals(fieldName)) {
instance.testLongObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Long.valueOf(jsonParser.getValueAsLong());
} else if ("test_string".equals(fieldName)) {
instance.testString = jsonParser.getValueAsString(null);
} else if ("test_t".equals(fieldName)) {
instance.testT = m84ClassJsonMapper.parse(jsonParser);
}
}
示例4: parseField
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public void parseField(MultipleFieldNamesModel instance, String fieldName, JsonParser jsonParser) throws IOException {
if ("possible_double_name_1".equals(fieldName) || "possible_double_name_2".equals(fieldName)) {
instance.testDouble = jsonParser.getValueAsDouble();
} else if ("possible_float_name_1".equals(fieldName) || "possible_float_name_2".equals(fieldName)){
instance.testFloat = (float)jsonParser.getValueAsDouble();
} else if ("possible_int_name_1".equals(fieldName) || "possible_int_name_2".equals(fieldName)){
instance.testInt = jsonParser.getValueAsInt();
} else if ("possible_long_name_1".equals(fieldName) || "possible_long_name_2".equals(fieldName)){
instance.testLong = jsonParser.getValueAsLong();
} else if ("possible_string_name_1".equals(fieldName) || "possible_string_name_2".equals(fieldName)){
instance.testString = jsonParser.getValueAsString(null);
}
}
示例5: parseField
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public void parseField(SimpleGenericModelWithExtends<T> instance, String fieldName, JsonParser jsonParser) throws IOException {
if ("date".equals(fieldName)) {
instance.date = getjava_util_Date_type_converter().parse(jsonParser);
} else if ("string".equals(fieldName)) {
instance.string = jsonParser.getValueAsString(null);
} else if ("test_double".equals(fieldName)) {
instance.testDouble = jsonParser.getValueAsDouble();
} else if ("test_double_obj".equals(fieldName)) {
instance.testDoubleObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Double.valueOf(jsonParser.getValueAsDouble());
} else if ("test_float".equals(fieldName)) {
instance.testFloat = (float)jsonParser.getValueAsDouble();
} else if ("test_float_obj".equals(fieldName)) {
instance.testFloatObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : new Float(jsonParser.getValueAsDouble());
} else if ("test_int".equals(fieldName)) {
instance.testInt = jsonParser.getValueAsInt();
} else if ("test_int_obj".equals(fieldName)) {
instance.testIntObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Integer.valueOf(jsonParser.getValueAsInt());
} else if ("test_long".equals(fieldName)) {
instance.testLong = jsonParser.getValueAsLong();
} else if ("test_long_obj".equals(fieldName)) {
instance.testLongObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Long.valueOf(jsonParser.getValueAsLong());
} else if ("test_string".equals(fieldName)) {
instance.testString = jsonParser.getValueAsString(null);
} else if ("test_t".equals(fieldName)) {
instance.testT = m84ClassJsonMapper.parse(jsonParser);
}
}
示例6: parseField
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public void parseField(BaseModel<T> instance, String fieldName, JsonParser jsonParser) throws IOException {
if ("createTime".equals(fieldName)) {
instance.createTime = jsonParser.getValueAsLong();
} else if ("data".equals(fieldName)) {
instance.data = mClassJsonMapper.parse(jsonParser);
} else if ("expire".equals(fieldName)) {
instance.expire = jsonParser.getValueAsLong();
} else if ("expireTime".equals(fieldName)) {
instance.expireTime = jsonParser.getValueAsLong();
} else if ("updateTime".equals(fieldName)) {
instance.updateTime = jsonParser.getValueAsLong();
}
}
示例7: jsonToColumnValue
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public Value jsonToColumnValue(final JsonParser parser, final ValueMetadata metadata) throws IOException {
JsonToken token;
Value value;
// Go to the next token
token = parser.nextToken();
if (token != JsonToken.VALUE_NUMBER_INT && token != JsonToken.VALUE_NULL) {
throw new IOException("Unable to parse field " + metadata.getName() + " expected int or null at line " + parser.getCurrentLocation().getLineNr());
}
// Can be a integer or null
if (token == JsonToken.VALUE_NUMBER_INT) {
value = new Value(parser.getValueAsLong(), metadata);
} else {
// null
if (metadata.isNotNull()) {
throw new IOException("Unable to parse field " + metadata.getName() + " expected int bu found null at line " + parser.getCurrentLocation().getLineNr());
}
value = new Value(metadata);
}
return value;
}
示例8: parseFieldName
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
private static void parseFieldName(JsonParser jsonParser, DeserializationContext deserializationContext,
JsonParsingContext parsingContext) throws IOException {
switch (jsonParser.getCurrentName()) {
case NodeInfoJsonSerializer.ID:
jsonParser.nextToken();
parsingContext.id = jsonParser.getValueAsString();
break;
case NodeInfoJsonSerializer.NAME:
jsonParser.nextToken();
parsingContext.name = jsonParser.getValueAsString();
break;
case NodeInfoJsonSerializer.PSEUDO_CLASS:
jsonParser.nextToken();
parsingContext.pseudoClass = jsonParser.getValueAsString();
break;
case NodeInfoJsonSerializer.DESCRIPTION:
jsonParser.nextToken();
parsingContext.description = jsonParser.getValueAsString();
break;
case NodeInfoJsonSerializer.CREATION_TIME:
jsonParser.nextToken();
parsingContext.creationTime = jsonParser.getValueAsLong();
break;
case NodeInfoJsonSerializer.MODIFICATION_TIME:
jsonParser.nextToken();
parsingContext.modificationTime = jsonParser.getValueAsLong();
break;
case NodeInfoJsonSerializer.VERSION:
jsonParser.nextToken();
parsingContext.version = jsonParser.getValueAsInt();
break;
case NodeInfoJsonSerializer.METADATA:
jsonParser.nextToken();
parsingContext.metadata = new NodeGenericMetadataJsonDeserializer().deserialize(jsonParser, deserializationContext);
break;
default:
throw new AssertionError("Unexpected field: " + jsonParser.getCurrentName());
}
}