Package org.json

Examples of org.json.JSONArray.optString()


    for (int i = 0; i < jsonMappings.length(); i++) {
      JSONArray entry = jsonMappings.getJSONArray(i);

      // The name can be accessed in two ways: Directly (i.e. a string) or
      // indirectly (i.e. an index into the name map).
      String name = entry.optString(3, "");
      if (names != null) {
        try {
          int nameIndex = entry.getInt(3);
          name = names.getString(nameIndex);
        } catch (JSONException e) {
View Full Code Here


        final JSONArray dArray = settings.optJSONArray(JSONOAuth2Persister.ALLOWED_DOMAINS);
        if (dArray != null) {
          final ArrayList<String> domains = new ArrayList<String>();
          for (int i = 0; i < dArray.length(); i++) {
            domains.add(dArray.optString(i));
          }
          client.setAllowedDomains(domains.toArray(new String[0]));
        }

        internalMap.put(clientName, client);
View Full Code Here

        assertEquals(0, gadget.getInt("moduleId"));
        first = true;
      } else {
        JSONArray errors = gadget.getJSONArray("errors");
        assertEquals(1, errors.length());
        assertEquals("broken", errors.optString(0));
        second = true;
      }
    }

    assertTrue("First gadget not returned!", first);
View Full Code Here

        final JSONArray dArray = settings.optJSONArray(JSONOAuth2Persister.ALLOWED_DOMAINS);
        if (dArray != null) {
          final ArrayList<String> domains = new ArrayList<String>();
          for (int i = 0; i < dArray.length(); i++) {
            domains.add(dArray.optString(i));
          }
          client.setAllowedDomains(domains.toArray(new String[0]));
        }

        internalMap.put(clientName, client);
View Full Code Here

    if (view == null) {
      JSONArray aliases = containerConfig.getJsonArray(context.getContainer(),
          "gadgets.features/views/" + viewName + "/aliases");
      if (aliases != null) {
        for (int i = 0, j = aliases.length(); i < j; ++i) {
          viewName = aliases.optString(i);
          if (viewName != null) {
            view = spec.getView(viewName);
            if (view != null) {
              break;
            }
View Full Code Here

        assertEquals(0, gadget.getInt("moduleId"));
        first = true;
      } else {
        JSONArray errors = gadget.getJSONArray("errors");
        assertEquals(1, errors.length());
        assertEquals("broken", errors.optString(0));
        second = true;
      }
    }

    assertTrue("First gadget not returned!", first);
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

            String[] keyNames = null;
            JSONArray keyArray = json.optJSONArray("keys");
            if (keyArray != null) {
                keyNames = new String[keyArray.length()];
                for (int i = 0; i < keyNames.length; ++i) {
                    keyNames[i] = keyArray.optString(i);
                }
            }

            String jevent = json.getString("object");
View Full Code Here

            String[] keyNames = null;
            JSONArray keyArray = json.optJSONArray("keys");
            if (keyArray != null) {
                keyNames = new String[keyArray.length()];
                for (int i = 0; i < keyNames.length; ++i) {
                    keyNames[i] = keyArray.optString(i);
                }
            }

            String jevent = json.getString("object");
View Full Code Here

    ArrayList<String> arCategories = new ArrayList<String>();
    for(int i=0; i<jhits.length(); i++){
      JSONObject jhit = jhits.getJSONObject(i);
      JSONArray jcolor = jhit.optJSONArray("color");
      if(jcolor != null){
        String color = jcolor.optString(0);
        if(color != null)
          arColors.add(color);
      }
      JSONArray jcategory = jhit.optJSONArray("category");
      if (jcategory != 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.