Package org.json

Examples of org.json.JSONObject.optInt()


        return status;

      /* extract available orgs */
      JSONObject orgs = status.getJsonData();

      if (orgs == null || orgs.optInt(CFProtocolConstants.V2_KEY_TOTAL_RESULTS, 0) < 1) {
        return new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NO_CONTENT, "Server did not return any organizations.", null);
      }

      /* look if the domain is available */
      JSONObject result = new JSONObject();
View Full Code Here


      if (json.has(KEY_TIMESTAMP))
        info.timestamp = new Date(json.getLong(KEY_TIMESTAMP));

      info.lengthComputable = json.optBoolean(KEY_LENGTH_COMPUTABLE);
      if (json.has(KEY_LOADED))
        info.loaded = json.optInt(KEY_LOADED);
      if (json.has(KEY_TOTAL))
        info.total = json.getInt(KEY_TOTAL);

      if (json.has(KEY_TYPE))
        info.status = TaskStatus.fromString(json.optString(KEY_TYPE));
View Full Code Here

    int port;
    try {
      JSONObject requestInfo = OrionServlet.readJSONRequest(request);
      host = requestInfo.getString(ProtocolConstants.KEY_HOST);
      remotePath = requestInfo.getString(ProtocolConstants.KEY_PATH);
      port = requestInfo.optInt(ProtocolConstants.KEY_PORT, 22);
      user = requestInfo.getString(ProtocolConstants.KEY_USER_NAME);
      passphrase = requestInfo.getString(ProtocolConstants.KEY_PASSPHRASE);
    } catch (Exception e) {
      handleException("Request body is not in the expected format", e, HttpServletResponse.SC_BAD_REQUEST);
      return;
View Full Code Here

    if (result.has("event")) {
      String eventName = result.getString("event");
      JSONObject params = result.optJSONObject("params");

      if (eventName.equals(EVENT_PAUSED)) {
        int isolateId = params.optInt("isolateId", -1);
        String reason = params.optString("reason", null);
        VmIsolate isolate = getCreateIsolate(isolateId);
        VmValue exception = VmValue.createFrom(isolate, params.optJSONObject("exception"));
        VmLocation location = VmLocation.createFrom(isolate, params.optJSONObject("location"));
View Full Code Here

        }
      }
      else if (eventName.equals(EVENT_BREAKPOINTRESOLVED)) {
        // { "event": "breakpointResolved", "params": {"breakpointId": 2, "url": "file:///Users/devoncarew/tools/eclipse_37/eclipse/samples/time/time_server.dart", "line": 19 }}

        int breakpointId = params.optInt("breakpointId");
        int isolateId = params.optInt("isolateId");
        VmIsolate isolate = getCreateIsolate(isolateId);
        VmLocation location = VmLocation.createFrom(isolate, params.getJSONObject("location"));

        handleBreakpointResolved(isolate, breakpointId, location);
View Full Code Here

      }
      else if (eventName.equals(EVENT_BREAKPOINTRESOLVED)) {
        // { "event": "breakpointResolved", "params": {"breakpointId": 2, "url": "file:///Users/devoncarew/tools/eclipse_37/eclipse/samples/time/time_server.dart", "line": 19 }}

        int breakpointId = params.optInt("breakpointId");
        int isolateId = params.optInt("isolateId");
        VmIsolate isolate = getCreateIsolate(isolateId);
        VmLocation location = VmLocation.createFrom(isolate, params.getJSONObject("location"));

        handleBreakpointResolved(isolate, breakpointId, location);
      }
View Full Code Here

      else if (eventName.equals(EVENT_ISOLATE)) {
        // { "event": "isolate", "params": { "reason": "created", "id": 7114 }}]
        // { "event": "isolate", "params": { "reason": "shutdown", "id": 7114 }}]

        String reason = params.optString("reason", null);
        int isolateId = params.optInt("id", -1);

        final VmIsolate isolate = getCreateIsolate(isolateId);

        if ("created".equals(reason)) {
          for (VmListener listener : listeners) {
View Full Code Here

            }
            return _data;
        } else if (data instanceof JSONObject) {
            JSONObject _data = (JSONObject)data;
            if (_data.optBoolean(KEY_PLACEHOLDER)) {
                int num = _data.optInt(KEY_NUM, -1);
                return num >= 0 && num < buffers.length ? buffers[num] : null;
            }
            Iterator<?> iterator = _data.keys();
            while (iterator.hasNext()) {
                String key = (String)iterator.next();
View Full Code Here

            } catch (JSONException ex) {
                logger.warning(String.format("JSON parsing failed for key %1s: %2s",
                        result.getRow(), ex.getMessage()));
            }
            if (jo != null) {
                int status = jo.optInt(PROPERTY_STATUS, -1);
                if (status >= 0) {
                    history.put(RecrawlAttributeConstants.A_STATUS, status);
                }
                String digest = jo.optString(PROPERTY_CONTENT_DIGEST);
                if (digest != null) {
View Full Code Here

    @Test
    public void testObject() {
        JSONObject json = OTJson.object("string", "string", "int", 123, "double", 123.456, "true", true, "false", false, "null", null);
        Assert.assertNotNull(json);
        Assert.assertEquals("string", json.optString("string"));
        Assert.assertEquals(123, json.optInt("int"));
        Assert.assertEquals(123.456, json.optDouble("double"), 1e-15);
        Assert.assertEquals(true, json.optBoolean("true"));
        Assert.assertEquals(false, json.optBoolean("false"));
        Assert.assertEquals(null, json.opt("null"));
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.