Package org.json

Examples of org.json.JSONArray.optInt()


  public List<RemoteWebElement> findElementsByCSSSelector(String selector) {
    JSONObject response = inspector.sendCommand(DOM.querySelectorAll(nodeId, selector));
    JSONArray nodesId = response.optJSONArray("nodeIds");
    ArrayList<RemoteWebElement> res = new ArrayList<RemoteWebElement>();
    for (int i = 0; i < nodesId.length(); i++) {
      NodeId id = new NodeId(nodesId.optInt(i));
      res.add(new RemoteWebElement(id, inspector));
    }
    return res;

  }
View Full Code Here


      for (int j = 0; j < charArray.length(); ++j) {
        // Keep track of the current mappingID, if the next element in the
        // array is empty we reuse the existing mappingID for the column.
        int mappingID = lastID;
        if (!charArray.isNull(j)) {
          mappingID = charArray.optInt(j);
          if (mappingID > maxID) {
            maxID = mappingID;
          }
        }
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

    @Test
    public void testArray() {
        JSONArray json = OTJson.array("string", 123, 123.456, true, false, null);
        Assert.assertNotNull(json);
        Assert.assertEquals("string", json.optString(0));
        Assert.assertEquals(123, json.optInt(1));
        Assert.assertEquals(123.456, json.optDouble(2), 1e-15);
        Assert.assertEquals(true, json.optBoolean(3));
        Assert.assertEquals(false, json.optBoolean(4));
        Assert.assertEquals(null, json.opt(5));
    }
View Full Code Here

      JSONArray array = obj.optJSONArray(field);
      if (array!=null){
      int count = array.length();
      intArray = new int[count];
      for (int i=0;i<count;++i){
        intArray[i] = array.optInt(i,defaultVal);
      }
      }
      return intArray;
    }
View Full Code Here

      JSONArray array = obj.optJSONArray(field);
      if (array!=null){
      int count = array.length();
      intSet = new HashSet<Integer>(count);
      for (int i=0;i<count;++i){
        intSet.add(array.optInt(i,defaultVal));
      }
      }
      return intSet;
    }
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.