Package org.json

Examples of org.json.JSONObject.opt()


        JSONObject previousArticle = articleRepository.getPreviousArticle(article.getString(Keys.OBJECT_ID));

        Assert.assertNotNull(previousArticle);
        Assert.assertEquals(previousArticle.getString(Article.ARTICLE_TITLE), "article title1");
        Assert.assertEquals(previousArticle.getString(Article.ARTICLE_PERMALINK), "article permalink1");
        Assert.assertNull(previousArticle.opt(Keys.OBJECT_ID));

        previousArticle = articleRepository.getByPermalink(previousArticle.getString(Article.ARTICLE_PERMALINK));

        final JSONObject nextArticle = articleRepository.getNextArticle(previousArticle.getString(Keys.OBJECT_ID));
        Assert.assertNotNull(previousArticle);
View Full Code Here


        JSONObject previousArticle = articleRepository.getPreviousArticle(article.getString(Keys.OBJECT_ID));

        Assert.assertNotNull(previousArticle);
        Assert.assertEquals(previousArticle.getString(Article.ARTICLE_TITLE), "article title1");
        Assert.assertEquals(previousArticle.getString(Article.ARTICLE_PERMALINK), "article permalink1");
        Assert.assertNull(previousArticle.opt(Keys.OBJECT_ID));

        previousArticle = articleRepository.getByPermalink(previousArticle.getString(Article.ARTICLE_PERMALINK));

        final JSONObject nextArticle = articleRepository.getNextArticle(previousArticle.getString(Keys.OBJECT_ID));
        Assert.assertNotNull(previousArticle);
View Full Code Here

        System.out.println("DBObject: " + bjson);

        assertNotNull(bjson);

        JSONObject jobj = (JSONObject) JsonSerializer.deserialize(bjson);
        Object obj = jobj.opt("object");
        System.out.println(obj);
        System.out.println(mock);
        assertTrue(obj.toString().replaceAll(" ", "").equalsIgnoreCase(mock.toString().replaceAll(" ", "")));

        Object lst = jobj.opt("list");
View Full Code Here

        Object obj = jobj.opt("object");
        System.out.println(obj);
        System.out.println(mock);
        assertTrue(obj.toString().replaceAll(" ", "").equalsIgnoreCase(mock.toString().replaceAll(" ", "")));

        Object lst = jobj.opt("list");
        System.out.println(lst);
        System.out.println(list);
    }
}
View Full Code Here

            if (temp == null) {
                throw new Exception(String.format("The node %s could not be found!", path));
            }
        }

        Object value = temp.opt(property);
        if (value == null) {
            throw new Exception(String.format("The node %s did not containt the property %s!", path, property));
        }
    }
View Full Code Here

    JSONObject clone = new JSONObject(base, JSONObject.getNames(base));
    // Walk parameter list for the merged object and merge recursively.
    String[] fields = JSONObject.getNames(merge);
    for (String field : fields) {
      Object existing = clone.opt(field);
      Object update = merge.get(field);
      if (JSONObject.NULL.equals(existing) || JSONObject.NULL.equals(update)) {
        // It's new custom config, not referenced in the prototype, or
        // it's removing a pre-configured value.
        clone.put(field, update);
View Full Code Here

    if (obj instanceof JSONObject) {
      JSONObject json = (JSONObject) obj;
     
      // Does this object have a "list" property that is an array?
      // TODO: add to specification
      Object childList = json.opt("list");
      if (childList != null && childList instanceof JSONArray) {
        return coerceToIterable(childList);
      }
     
      // A scalar JSON value is treated as a single element list.
View Full Code Here

      return new Result<List<TenpayAddress>>(error);
    }
    List<TenpayAddress> addresses = new ArrayList<TenpayAddress>();
    Integer total = Result.parseInteger(jsonObject.get("ret_num"));
    for (int i = 0; i < total; i++) {
      Integer index = Result.parseInteger(jsonObject.opt("Findex_" + i));
      if (index == null) {
        break;
      }
      TenpayAddress address = new TenpayAddress();
      address.setTotal(total);
View Full Code Here

        break;
      }
      TenpayAddress address = new TenpayAddress();
      address.setTotal(total);
      address.setIndex(index);
      address.setRegionId(Result.parseInteger(jsonObject.opt("FRegionId_" + i)));
      address.setStreet(jsonObject.optString("Faddrstreet_" + i));
      address.setZipcode(Result.toString(jsonObject.opt("Fzipcode_" + i)));
      address.setMobile(Result.toString(jsonObject.opt("Fmobile_" + i)));
      address.setTel(Result.toString(jsonObject.opt("Ftel_" + i)));
      address.setName(Result.toString(jsonObject.opt("Fname_" + i)));
View Full Code Here

      TenpayAddress address = new TenpayAddress();
      address.setTotal(total);
      address.setIndex(index);
      address.setRegionId(Result.parseInteger(jsonObject.opt("FRegionId_" + i)));
      address.setStreet(jsonObject.optString("Faddrstreet_" + i));
      address.setZipcode(Result.toString(jsonObject.opt("Fzipcode_" + i)));
      address.setMobile(Result.toString(jsonObject.opt("Fmobile_" + i)));
      address.setTel(Result.toString(jsonObject.opt("Ftel_" + i)));
      address.setName(Result.toString(jsonObject.opt("Fname_" + i)));
      address.setCreated(Result.parseDate(jsonObject.opt("Fcreate_time_" + i),
          "yyyy-MM-dd HH:mm:ss", Locale.CHINA));
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.