本文整理匯總了Java中com.fasterxml.jackson.core.JsonParser.getLongValue方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonParser.getLongValue方法的具體用法?Java JsonParser.getLongValue怎麽用?Java JsonParser.getLongValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.fasterxml.jackson.core.JsonParser
的用法示例。
在下文中一共展示了JsonParser.getLongValue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: deserialize
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
public static YieldMessage deserialize(JsonParser jp) throws IOException {
jp.nextToken();
long request = jp.getLongValue();
jp.nextToken();
ParserUtil.readObject(jp);
List<Object> arguments = null;
JsonToken token = jp.nextToken();
if (token == JsonToken.START_ARRAY) {
arguments = ParserUtil.readArray(jp);
}
Map<String, Object> argumentsKw = null;
token = jp.nextToken();
if (token == JsonToken.START_OBJECT) {
argumentsKw = ParserUtil.readObject(jp);
}
return new YieldMessage(request, arguments, argumentsKw);
}
示例2: deserialize
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
public static RegisterMessage deserialize(JsonParser jp) throws IOException {
jp.nextToken();
long request = jp.getLongValue();
boolean discloseCaller = false;
jp.nextToken();
Map<String, Object> options = ParserUtil.readObject(jp);
if (options != null) {
discloseCaller = (boolean) options.getOrDefault("disclose_caller", false);
}
jp.nextToken();
String procedure = jp.getValueAsString();
return new RegisterMessage(request, procedure, discloseCaller);
}
示例3: deserialize
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
public static RegisteredMessage deserialize(JsonParser jp) throws IOException {
jp.nextToken();
long request = jp.getLongValue();
jp.nextToken();
long registration = jp.getLongValue();
return new RegisteredMessage(request, registration);
}
示例4: parse
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public Long parse(JsonParser jsonParser) throws IOException {
if (jsonParser.getCurrentToken() == JsonToken.VALUE_NULL) {
return null;
} else {
return jsonParser.getLongValue();
}
}
示例5: parsePerson
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
public static void parsePerson() {
try {
JsonFactory jsonfactory = new JsonFactory();
JsonParser parser = jsonfactory.createParser(new File("Person.json"));
while (parser.nextToken() != JsonToken.END_OBJECT) {
String token = parser.getCurrentName();
if ("firstname".equals(token)) {
parser.nextToken();
String fname = parser.getText();
out.println("firstname : " + fname);
}
if ("lastname".equals(token)) {
parser.nextToken();
String lname = parser.getText();
out.println("lastname : " + lname);
}
if ("phone".equals(token)) {
parser.nextToken();
long phone = parser.getLongValue();
out.println("phone : " + phone);
}
if ("address".equals(token)) {
out.println("address :");
parser.nextToken();
while (parser.nextToken() != JsonToken.END_ARRAY) {
out.println(parser.getText());
}
}
}
parser.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
開發者ID:PacktPublishing,項目名稱:Machine-Learning-End-to-Endguide-for-Java-developers,代碼行數:36,代碼來源:JSONExamples.java
示例6: parsePerson
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
public void parsePerson(JsonParser parser) throws IOException {
while (parser.nextToken() != JsonToken.END_ARRAY) {
String token = parser.getCurrentName();
if ("firstname".equals(token)) {
parser.nextToken();
String fname = parser.getText();
out.println("firstname : " + fname);
}
if ("lastname".equals(token)) {
parser.nextToken();
String lname = parser.getText();
out.println("lastname : " + lname);
}
if ("phone".equals(token)) {
parser.nextToken();
long phone = parser.getLongValue();
out.println("phone : " + phone);
}
if ("address".equals(token)) {
out.println("address :");
parser.nextToken();
while (parser.nextToken() != JsonToken.END_ARRAY) {
out.println(parser.getText());
}
}
}
}
示例7: deserialize
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public Long deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
if (p.hasToken(JsonToken.VALUE_NUMBER_INT)) {
return p.getLongValue();
}
if (p.hasToken(JsonToken.VALUE_STRING)) {
return Instant.parse(p.getText()).toEpochMilli();
}
return 0L;
}
示例8: deserialize
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
public static UnsubscribeMessage deserialize(JsonParser jp) throws IOException {
jp.nextToken();
long request = jp.getLongValue();
jp.nextToken();
long subscription = jp.getLongValue();
return new UnsubscribeMessage(request, subscription);
}
示例9: deserialize
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
public static ErrorMessage deserialize(JsonParser jp) throws IOException {
jp.nextToken();
int type = jp.getIntValue();
jp.nextToken();
long request = jp.getLongValue();
jp.nextToken();
ParserUtil.readObject(jp);
jp.nextToken();
String error = jp.getValueAsString();
List<Object> arguments = null;
JsonToken token = jp.nextToken();
if (token == JsonToken.START_ARRAY) {
arguments = ParserUtil.readArray(jp);
}
Map<String, Object> argumentsKw = null;
token = jp.nextToken();
if (token == JsonToken.START_OBJECT) {
argumentsKw = ParserUtil.readObject(jp);
}
return new ErrorMessage(type, request, error, arguments, argumentsKw);
}
示例10: deserialize
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
public static InvocationMessage deserialize(JsonParser jp) throws IOException {
jp.nextToken();
long request = jp.getLongValue();
jp.nextToken();
long registration = jp.getLongValue();
jp.nextToken();
Number caller = null;
Map<String, Object> details = ParserUtil.readObject(jp);
if (details != null) {
caller = (Number) details.get("caller");
}
List<Object> arguments = null;
JsonToken token = jp.nextToken();
if (token == JsonToken.START_ARRAY) {
arguments = ParserUtil.readArray(jp);
}
Map<String, Object> argumentsKw = null;
token = jp.nextToken();
if (token == JsonToken.START_OBJECT) {
argumentsKw = ParserUtil.readObject(jp);
}
return new InvocationMessage(request, registration, caller, arguments,
argumentsKw);
}
示例11: deserialize
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
public static UnregisterMessage deserialize(JsonParser jp) throws IOException {
jp.nextToken();
long request = jp.getLongValue();
jp.nextToken();
long registration = jp.getLongValue();
return new UnregisterMessage(request, registration);
}
示例12: deserialize
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
public static PublishedMessage deserialize(JsonParser jp) throws IOException {
jp.nextToken();
long request = jp.getLongValue();
jp.nextToken();
long subscription = jp.getLongValue();
return new PublishedMessage(request, subscription);
}
示例13: deserialize
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
public static CallMessage deserialize(JsonParser jp) throws IOException {
jp.nextToken();
long request = jp.getLongValue();
boolean discloseMe = false;
jp.nextToken();
Map<String, Object> options = ParserUtil.readObject(jp);
if (options != null) {
discloseMe = (boolean) options.getOrDefault("disclose_me", false);
}
jp.nextToken();
String procedure = jp.getValueAsString();
List<Object> arguments = null;
JsonToken token = jp.nextToken();
if (token == JsonToken.START_ARRAY) {
arguments = ParserUtil.readArray(jp);
}
Map<String, Object> argumentsKw = null;
token = jp.nextToken();
if (token == JsonToken.START_OBJECT) {
argumentsKw = ParserUtil.readObject(jp);
}
return new CallMessage(request, procedure, arguments, argumentsKw, discloseMe);
}
示例14: deserialize
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public static WelcomeMessage deserialize(JsonParser jp) throws IOException {
jp.nextToken();
long session = jp.getLongValue();
List<WampRole> roles = new ArrayList<>();
String realm = null;
jp.nextToken();
Map<String, Object> details = ParserUtil.readObject(jp);
if (details != null) {
Map<String, Map<String, Map<String, Boolean>>> rolesMap = (Map<String, Map<String, Map<String, Boolean>>>) details
.get("roles");
for (Map.Entry<String, Map<String, Map<String, Boolean>>> entry : rolesMap
.entrySet()) {
WampRole wampRole = new WampRole(entry.getKey());
Map<String, Boolean> features = entry.getValue().get("features");
if (features != null) {
for (String feature : features.keySet()) {
wampRole.addFeature(feature);
}
}
roles.add(wampRole);
}
realm = (String) details.get("realm");
}
return new WelcomeMessage(session, roles, realm);
}
示例15: parseLong
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
/** Parses a long out of the input, using the optimized path when the value is not quoted. */
private static long parseLong(JsonParser parser) throws IOException {
if (parser.currentToken() == JsonToken.VALUE_NUMBER_INT) {
return parser.getLongValue();
}
return NumberInput.parseLong(parser.getText());
}