当前位置: 首页>>代码示例>>Java>>正文


Java JsonObject.getBoolean方法代码示例

本文整理汇总了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;
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:23,代码来源:RemoteIOSWebDriver.java

示例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;
}
 
开发者ID:hustlebar,项目名称:hustic,代码行数:19,代码来源:GetResponseHandler.java

示例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);
  }
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:22,代码来源:User.java

示例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);
    }
}
 
开发者ID:dainesch,项目名称:HueSense,代码行数:24,代码来源:PresenceSensor.java

示例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);
    }
}
 
开发者ID:dainesch,项目名称:HueSense,代码行数:25,代码来源:LightSensor.java

示例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");
}
 
开发者ID:Hockeyfan360,项目名称:Capatchafy,代码行数:41,代码来源:CapatchaPage.java

示例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);
	}
}
 
开发者ID:howma03,项目名称:sporticus,代码行数:57,代码来源:ServiceRecapchaImpl.java

示例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"));
}
 
开发者ID:curityio,项目名称:oauth-filter-for-java,代码行数:9,代码来源:OpaqueTokenValidator.java

示例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);
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:9,代码来源:DevtoolsDebugger.java

示例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);
  }
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:8,代码来源:WebInspectorHelper.java

示例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;
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:29,代码来源:AddCookieHandler.java


注:本文中的javax.json.JsonObject.getBoolean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。