本文整理汇总了Java中javax.json.JsonObject.getBoolean方法的典型用法代码示例。如果您正苦于以下问题:Java JsonObject.getBoolean方法的具体用法?Java JsonObject.getBoolean怎么用?Java JsonObject.getBoolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.json.JsonObject
的用法示例。
在下文中一共展示了JsonObject.getBoolean方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCookies
import javax.json.JsonObject; //导入方法依赖的package包/类
public List<Cookie> getCookies() {
List<Cookie> res = new ArrayList<>();
JsonObject o = inspector.sendCommand(Page.getCookies());
JsonArray cookies = o.getJsonArray("cookies");
if (cookies != null) {
for (int i = 0; i < cookies.size(); i++) {
JsonObject cookie = cookies.getJsonObject(i);
String name = cookie.getString("name");
String value = cookie.getString("value");
String domain = cookie.getString("domain");
String path = cookie.getString("path");
Date expiry = new Date(cookie.getJsonNumber("expires").longValue());
boolean isSecure = cookie.getBoolean("secure");
Cookie c = new Cookie(name, value, domain, path, expiry, isSecure);
res.add(c);
}
return res;
} else {
// TODO
}
return null;
}
示例2: handleResponse
import javax.json.JsonObject; //导入方法依赖的package包/类
@Override
public GetResponse handleResponse(HttpResponse httpResponse) throws IOException {
int code = httpResponse.getStatusLine().getStatusCode();
GetResponse getResponse = new GetResponse(code);
if (code != 200) {
}
InputStream content = httpResponse.getEntity().getContent();
JsonObject responseJson = Json.createReader(content).readObject();
boolean isFound = responseJson.getBoolean("found");
if (!isFound) {
return getResponse;
}
getResponse.setData(getData(responseJson));
return getResponse;
}
示例3: User
import javax.json.JsonObject; //导入方法依赖的package包/类
/** Constructor for reading the user from the JSON that was a part of a JAX-RS request. */
public User(JsonObject user) {
if (user.containsKey(JSON_KEY_USER_ID)) {
id = user.getString(JSON_KEY_USER_ID);
}
this.firstName = user.getString(JSON_KEY_USER_FIRST_NAME, "");
this.lastName = user.getString(JSON_KEY_USER_LAST_NAME, "");
this.twitterHandle = user.getString(JSON_KEY_USER_TWITTER_HANDLE, "");
this.wishListLink = user.getString(JSON_KEY_USER_WISH_LIST_LINK, "");
this.isTwitterLogin = user.getBoolean(JSON_KEY_USER_TWITTER_LOGIN, false);
if (user.containsKey(JSON_KEY_USER_NAME)) {
this.userName = user.getString(JSON_KEY_USER_NAME);
}
if (user.containsKey(JSON_KEY_USER_PASSWORD_HASH)) {
this.passwordHash = user.getString(JSON_KEY_USER_PASSWORD_HASH);
}
if (user.containsKey(JSON_KEY_USER_PASSWORD_SALT)) {
this.passwordSalt = user.getString(JSON_KEY_USER_PASSWORD_SALT);
}
}
示例4: updateSensor
import javax.json.JsonObject; //导入方法依赖的package包/类
@Override
public void updateSensor(JsonObject obj) throws UpdateException {
try {
setName(obj.getString("name"));
JsonObject state = obj.getJsonObject("state");
Boolean pres = state.getBoolean("presence");
SimpleDateFormat sdf = new SimpleDateFormat(Constants.HUEDATEFORMAT);
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
Date time = sdf.parse(state.getString("lastupdated"));
SensorValue<Boolean> val = new SensorValue<>(time, pres);
updateValue(val);
JsonObject conf = obj.getJsonObject("config");
setOn(conf.getBoolean("on"));
setBattery(conf.getInt("battery"));
setReachable(conf.getBoolean("reachable"));
} catch (ParseException | NullPointerException | ClassCastException ex) {
throw new UpdateException("Error updating temp sensor", ex);
}
}
示例5: updateSensor
import javax.json.JsonObject; //导入方法依赖的package包/类
@Override
public void updateSensor(JsonObject obj) throws UpdateException {
try {
setName(obj.getString("name"));
JsonObject state = obj.getJsonObject("state");
SimpleDateFormat sdf = new SimpleDateFormat(Constants.HUEDATEFORMAT);
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
Date time = sdf.parse(state.getString("lastupdated"));
LightLevel level = new LightLevel(state.getInt("lightlevel"), state.getBoolean("dark"), state.getBoolean("daylight"));
SensorValue<LightLevel> val = new SensorValue<>(time, level);
updateValue(val);
JsonObject conf = obj.getJsonObject("config");
setOn(conf.getBoolean("on"));
setBattery(conf.getInt("battery"));
setReachable(conf.getBoolean("reachable"));
} catch (ParseException | NullPointerException | ClassCastException ex) {
throw new UpdateException("Error updating temp sensor", ex);
}
}
示例6: validateCaptcha
import javax.json.JsonObject; //导入方法依赖的package包/类
public boolean validateCaptcha(String secret, String response, String remoteip)
{
JsonObject jsonObject = null;
URLConnection connection = null;
InputStream is = null;
String charset = java.nio.charset.StandardCharsets.UTF_8.name();
String url = "https://www.google.com/recaptcha/api/siteverify";
try
{
String query = String.format("secret=%s&response=%s&remoteip=%s",
URLEncoder.encode(secret, charset),
URLEncoder.encode(response, charset),
URLEncoder.encode(remoteip, charset));
connection = new URL(url + "?" + query).openConnection();
is = connection.getInputStream();
JsonReader rdr = Json.createReader(is);
jsonObject = rdr.readObject();
}
catch (IOException ex)
{
Bukkit.broadcastMessage(ex.getStackTrace().toString());
}
finally
{
if (is != null)
{
try
{
is.close();
}
catch (IOException e)
{
System.out.print(e.getLocalizedMessage());
}
}
}
return jsonObject.getBoolean("success");
}
示例7: verify
import javax.json.JsonObject; //导入方法依赖的package包/类
@Override
public void verify(String gRecaptchaResponse) throws RecaptchaException {
if (gRecaptchaResponse == null || "".equals(gRecaptchaResponse)) {
throw new RecaptchaException("Recapcha failed");
}
try {
URL obj = new URL(url);
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
// add request header
con.setRequestMethod("POST");
con.setRequestProperty("User-Agent", USER_AGENT);
con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
String postParams = "secret=" + secret + "&response="
+ gRecaptchaResponse;
// Send post request
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(postParams);
wr.flush();
wr.close();
int responseCode = con.getResponseCode();
System.out.println("\nSending 'POST' request to URL : " + url);
System.out.println("Post parameters : " + postParams);
System.out.println("Response Code : " + responseCode);
BufferedReader in = new BufferedReader(new InputStreamReader(
con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
// print result
System.out.println(response.toString());
//parse JSON response and return 'success' value
JsonReader jsonReader = Json.createReader(new StringReader(response.toString()));
JsonObject jsonObject = jsonReader.readObject();
jsonReader.close();
if (!jsonObject.getBoolean("success")) {
throw new RecaptchaException("Recapcha failed");
}
} catch (Exception e) {
throw new RecaptchaException("Recaptcha failed", e);
}
}
示例8: parseIntrospectResponse
import javax.json.JsonObject; //导入方法依赖的package包/类
private OAuthIntrospectResponse parseIntrospectResponse(String introspectJson)
{
JsonReader jsonReader = _jsonReaderFactory.createReader(new StringReader(introspectJson));
JsonObject jsonObject = jsonReader.readObject();
return new OAuthIntrospectResponse(jsonObject.getBoolean("active"), jsonObject.getString("sub"),
jsonObject.getString("scope"), jsonObject.getInt("exp"));
}
示例9: convertResponseToResult
import javax.json.JsonObject; //导入方法依赖的package包/类
@VisibleForTesting
static final DevtoolsResult convertResponseToResult(DevtoolsCommand command, JsonObject response)
throws DevtoolsErrorException {
if (response.containsKey("error") || response.getBoolean("wasThrown", false)) {
throw new DevtoolsErrorException(command, response);
}
return DevtoolsResult.fromJson(response);
}
示例10: checkForJSErrors
import javax.json.JsonObject; //导入方法依赖的package包/类
public void checkForJSErrors(JsonObject response) {
if (response.getBoolean("wasThrown")) {
JsonObject details = response.getJsonObject("result");
String desc = details.getString("description");
throw new WebDriverException("JS error :" + desc);
}
}
示例11: handle
import javax.json.JsonObject; //导入方法依赖的package包/类
@Override
public Response handle() throws Exception {
JsonObject payload = getRequest().getPayload();
JsonObject cookie = payload.getJsonObject("cookie");
String name = cookie.getString("name", "");
String value = cookie.getString("value", "");
String path = cookie.getString("path", "/");
String domain;
if (cookie.containsKey("domain")) {
domain = cookie.getString("domain");
} else {
URL url = new URL(getWebDriver().getCurrentUrl());
domain = url.getHost();
}
boolean secure = cookie.getBoolean("secure", false);
boolean httpOnly = cookie.getBoolean("httpOnly", false);
Instant expiry =
cookie.containsKey("expiry")
? Instant.ofEpochSecond(cookie.getJsonNumber("expiry").longValueExact())
: OffsetDateTime.now(ZoneOffset.UTC).plusYears(20).toInstant();
getWebDriver().addCookie(name, value, path, domain, secure, httpOnly, expiry);
Response res = new Response();
res.setSessionId(getSession().getSessionId());
res.setStatus(0);
return res;
}