本文整理匯總了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;
}
}