本文整理汇总了Java中javax.json.JsonReader.read方法的典型用法代码示例。如果您正苦于以下问题:Java JsonReader.read方法的具体用法?Java JsonReader.read怎么用?Java JsonReader.read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.json.JsonReader
的用法示例。
在下文中一共展示了JsonReader.read方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isStatusOk
import javax.json.JsonReader; //导入方法依赖的package包/类
/**
* Says if status is OK
* @return true if status is OK
*/
public boolean isStatusOk() {
if (jsonResult == null || jsonResult.isEmpty()) {
return false;
}
try {
JsonReader reader = Json.createReader(new StringReader(jsonResult));
JsonStructure jsonst = reader.read();
JsonObject object = (JsonObject) jsonst;
JsonString status = (JsonString) object.get("status");
if (status != null && status.getString().equals("OK")) {
return true;
} else {
return false;
}
} catch (Exception e) {
this.parseException = e;
invalidJsonStream = true;
return false;
}
}
示例2: getValue
import javax.json.JsonReader; //导入方法依赖的package包/类
/**
* Returns the value for a name
* @param name
* @return the value
*/
public String getValue(String name) {
if (name == null) {
throw new NullPointerException("name is null!");
}
if (isInvalidJsonStream()) {
return null;
}
try {
JsonReader reader = Json.createReader(new StringReader(jsonResult));
JsonStructure jsonst = reader.read();
JsonObject object = (JsonObject) jsonst;
JsonString value = (JsonString) object.get(name);
if (value == null) {
return null;
}
return value.getString();
} catch (Exception e) {
this.parseException = e;
return null;
}
}
示例3: getIntvalue
import javax.json.JsonReader; //导入方法依赖的package包/类
/**
* Returns the int value for a name
* @param name
* @return the value
*/
public int getIntvalue(String name) {
if (name == null) {
throw new NullPointerException("name is null!");
}
if (isInvalidJsonStream()) {
return -1;
}
try {
JsonReader reader = Json.createReader(new StringReader(jsonResult));
JsonStructure jsonst = reader.read();
JsonObject object = (JsonObject) jsonst;
JsonNumber value = (JsonNumber) object.get(name);
if (value == null) {
return -1;
}
return value.intValue();
} catch (Exception e) {
this.parseException = e;
return -1;
}
}
示例4: getErrorType
import javax.json.JsonReader; //导入方法依赖的package包/类
/**
* Returns the error_type in case of failure
* @return the error_type in case of failure, -1 if no error
*/
public int getErrorType() {
if (isInvalidJsonStream()) {
return 0;
}
try {
JsonReader reader = Json.createReader(new StringReader(jsonResult));
JsonStructure jsonst = reader.read();
JsonObject object = (JsonObject) jsonst;
JsonString status = (JsonString) object.get("status");
if (status == null) {
return -1;
}
JsonNumber errorType = (JsonNumber) object.get("error_type");
if (errorType == null) {
return -1;
}
else {
return errorType.intValue();
}
} catch (Exception e) {
this.parseException = e;
return -1;
}
}
示例5: getStackTrace
import javax.json.JsonReader; //导入方法依赖的package包/类
/**
* Returns the stack_trace in case of failure
* @return the stack_trace in case of failure, null if no stack_trace
*/
public String getStackTrace() {
if (isInvalidJsonStream()) {
return null;
}
try {
JsonReader reader = Json.createReader(new StringReader(jsonResult));
JsonStructure jsonst = reader.read();
JsonObject object = (JsonObject) jsonst;
JsonString status = (JsonString) object.get("status");
if (status == null) {
return null;
}
JsonString stackTrace = (JsonString) object.get("stack_trace");
if (stackTrace == null) {
return null;
}
else {
return stackTrace.getString();
}
} catch (Exception e) {
this.parseException = e;
return null;
}
}