Package org.json

Examples of org.json.JSONObject.opt()


      if (probe) {
        log();
      }
      final String name = read(this.namehuff, this.namehuffext,
          this.namekeep);
      if (jsonobject.opt(name) != null) {
        throw new JSONException("Duplicate key.");
      }
      jsonobject.put(
          name,
          !bit() ? read(this.stringhuff, this.stringhuffext,
View Full Code Here


                return false;
            }
            Iterator<?> keys = jsonExpected.keys();
            while (keys.hasNext()) {
                String key = (String)keys.next();
                if (!isJSONEquals(jsonExpected.opt(key), jsonActual.opt(key))) {
                    return false;
                }
            }
            return true;
        }
View Full Code Here

            JSONArray jsonActual = (JSONArray)actual;
            if (jsonExpected.length() != jsonActual.length()) {
                return false;
            }
            for (int i = 0; i < jsonExpected.length(); ++i) {
                if (!isJSONEquals(jsonExpected.opt(i), jsonActual.opt(i))) {
                    return false;
                }
            }
            return true;
        }
View Full Code Here

    }

    @Override
    public JSONObject getPreviousArticle(final String articleId) throws RepositoryException {
        final JSONObject currentArticle = get(articleId);
        final Date currentArticleCreateDate = (Date) currentArticle.opt(Article.ARTICLE_CREATE_DATE);

        final Query query = new Query().setFilter(CompositeFilterOperator.and(new PropertyFilter(Article.ARTICLE_CREATE_DATE, FilterOperator.LESS_THAN, currentArticleCreateDate), new PropertyFilter(Article.ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, true))).addSort(Article.ARTICLE_CREATE_DATE, SortDirection.DESCENDING).setCurrentPageNum(1).setPageSize(1).setPageCount(1).addProjection(Article.ARTICLE_TITLE, String.class).addProjection(
            Article.ARTICLE_PERMALINK, String.class);

        final JSONObject result = get(query);
View Full Code Here

    }

    @Override
    public JSONObject getNextArticle(final String articleId) throws RepositoryException {
        final JSONObject currentArticle = get(articleId);
        final Date currentArticleCreateDate = (Date) currentArticle.opt(Article.ARTICLE_CREATE_DATE);

        final Query query = new Query().setFilter(CompositeFilterOperator.and(new PropertyFilter(Article.ARTICLE_CREATE_DATE, FilterOperator.GREATER_THAN, currentArticleCreateDate), new PropertyFilter(Article.ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, true))).addSort(Article.ARTICLE_CREATE_DATE, SortDirection.ASCENDING).setCurrentPageNum(1).setPageSize(1).setPageCount(1).addProjection(Article.ARTICLE_TITLE, String.class).addProjection(
            Article.ARTICLE_PERMALINK, String.class);

        final JSONObject result = get(query);
View Full Code Here

    }

    @Override
    public JSONObject getPreviousArticle(final String articleId) throws RepositoryException {
        final JSONObject currentArticle = get(articleId);
        final Date currentArticleCreateDate = (Date) currentArticle.opt(Article.ARTICLE_CREATE_DATE);

        final Query query = new Query().addFilter(Article.ARTICLE_CREATE_DATE, FilterOperator.LESS_THAN, currentArticleCreateDate).
                addFilter(Article.ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, true).
                addSort(Article.ARTICLE_CREATE_DATE, SortDirection.DESCENDING).setCurrentPageNum(1).
                setPageSize(1).setPageCount(1).
View Full Code Here

    }

    @Override
    public JSONObject getNextArticle(final String articleId) throws RepositoryException {
        final JSONObject currentArticle = get(articleId);
        final Date currentArticleCreateDate = (Date) currentArticle.opt(Article.ARTICLE_CREATE_DATE);

        final Query query = new Query().addFilter(Article.ARTICLE_CREATE_DATE, FilterOperator.GREATER_THAN, currentArticleCreateDate).
                addFilter(Article.ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, true).
                addSort(Article.ARTICLE_CREATE_DATE, SortDirection.ASCENDING).setCurrentPageNum(1).
                setPageSize(1).setPageCount(1).
View Full Code Here

    public static FunctionRequest decodeRequest(Reader r) throws IOException, JSONException {
        JSONTokener t = new JSONTokener(r);
        JSONObject jo = new JSONObject(t);
        String name = jo.getString("name");
        JSONArray args = jo.getJSONArray("args");
        String sheetName = (String) jo.opt("sheetName");
        JSONObject caller = (JSONObject) jo.opt("caller");
        XLSRef cref = null;
        if (caller != null) {
            cref = (XLSRef) decode(caller);
        }
View Full Code Here

            for( PropertyDescriptor persistentProperty : actualValueType.properties() )
            {
                Object valueJson = null;
                try
                {
                    valueJson = jsonObject.opt( persistentProperty.qualifiedName().name() );

                    Object value = null;
                    if( valueJson != null && !valueJson.equals( JSONObject.NULL ) )
                    {
                        value = deserialize( valueJson, persistentProperty.valueType() );
View Full Code Here

            if (binaryData == null) {
               return;
            }
            JSONObject payload = new JSONObject(binaryData.toString(CharsetUtil.UTF_8));
            String opCode = (String) payload.get(OpHandler.OP_CODE);
            String cacheName = (String) payload.opt(OpHandler.CACHE_NAME);
            Cache<Object, Object> cache = getCache(cacheName);
           
            OpHandler handler = operationHandlers.get(opCode);
            if (handler != null) {
               handler.handleOp(payload, cache, ctx);
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.