Package org.json

Examples of org.json.JSONArray.optJSONObject()


      jsonArray = jsonObject.optJSONArray("tweet");
    }
    if (jsonArray != null) {
      List<TweetInfo> tweets = new ArrayList<TweetInfo>();
      for (int i = 0; i < jsonArray.length(); i++) {
        tweets.add(TweetInfo.parse(jsonArray.optJSONObject(i)));
      }
      obj.tweets = tweets;
    }
    obj.tweetNum = Result.parseInteger(jsonObject.opt("tweetnum"));
    obj.verifyInfo = Result.toString(jsonObject.opt("verifyinfo"));
View Full Code Here


    SenseiHit senseiHit =  JsonDeserializer.deserialize(SenseiHit.class, json, false);
    JSONArray storedFieldsArr = json.optJSONArray("stored");
    if (storedFieldsArr != null) {
      List<FieldValue> storedFields = new ArrayList<FieldValue>(storedFieldsArr.length());
      for (int i = 0; i< storedFieldsArr.length(); i++) {
        JSONObject storedJson = storedFieldsArr.optJSONObject(i);
        if (storedJson != null) {
          String fieldName = (String) storedJson.keys().next();
          storedFields.add(new FieldValue(fieldName, storedJson.optString(fieldName)));
        }
      }
View Full Code Here

            }
        }
        JSONArray facetsList = schemaObj.optJSONArray("facets");
        if (facetsList != null) {
            for (int i = 0; i < facetsList.length(); i++) {
                JSONObject facet = facetsList.optJSONObject(i);
                if (facet != null) {
                    schema.facets.add(FacetDefinition.valueOf(facet));
                }
            }
        }
View Full Code Here

            }
        }
        JSONArray facetsList = schemaObj.optJSONArray("facets");
        if (facetsList != null) {
            for (int i = 0; i < facetsList.length(); i++) {
                JSONObject facet = facetsList.optJSONObject(i);
                if (facet != null) {
                    schema.facets.add(FacetDefinition.valueOf(facet));
                }
            }
        }
View Full Code Here

      else if (selections instanceof JSONArray)
      {
        JSONArray selectionArray = (JSONArray)selections;
        for(int i=0; i<selectionArray.length(); i++)
        {
          JSONObject selItem = selectionArray.optJSONObject(i);
          if(selItem != null){
            Iterator<String> keyIter = selItem.keys();
            while(keyIter.hasNext()){
              String type = keyIter.next();
              JSONObject jsonSel = selItem.optJSONObject(type);
View Full Code Here

    // Check for work
    if( null != changesDoc ){
      JSONArray results = changesDoc.optJSONArray("results");
      if( null != results ){
        for(int i=0; i<results.length(); ++i){
          JSONObject changeObj = results.optJSONObject(i);
          if( null != changeObj ){
            try {
              reportChanges(changeObj);
            } catch (Exception e) {
              logger.error("Error interpreting database changes",e);
View Full Code Here

      String json = cr.readResponseAsCharacters();
      JSONObject jso = new JSONObject(json);
      String nextStart = jso.getString("nextStart");
      JSONArray records = jso.getJSONArray("results");
      for (int idx = 0; idx < records.length(); idx++) {
          JSONObject record = records.optJSONObject(idx);
          ESRI_ItemInformation ii = itemInfoAdapter.toItemInfo(record);
          infos.add(ii);
      }
      return new SearchResult(new SearchParams(params.getQuery(), params.getNum(), Val.chkInt(nextStart, -1)), infos);
    } catch (JSONException ex) {
View Full Code Here

    this.key = null;
    this.targetClass = jsonObject.optString("className", null);
    JSONArray objectsArray = jsonObject.optJSONArray("objects");
    if (objectsArray != null) {
      for (int i = 0; i < objectsArray.length(); i++) {
        this.knownObjects.add((T) ParseDecoder.decode(objectsArray
            .optJSONObject(i)));
      }
    }
  }
View Full Code Here

                       "Added query result[cacheKey={0}] in repository cache[{1}]",
                       new Object[]{cacheKey, getName()});
            // Checks if the result is a single result
            final JSONArray results = ret.optJSONArray(Keys.RESULTS);
            if (1 == results.length()) {
                final JSONObject jsonObject = results.optJSONObject(0);

                // Checks if the single result is an entity
                if (jsonObject.has(Keys.OBJECT_ID)) {
                    // If it is an entity, put its key into cache
                    CACHE.put(CACHE_KEY_PREFIX
View Full Code Here

            return ret;
        }

        final JSONArray repositories = repositoriesDescription.optJSONArray("repositories");
        for (int i = 0; i < repositories.length(); i++) {
            final JSONObject repository = repositories.optJSONObject(i);
            ret.put(repository.optString("name"));
        }

        return ret;
    }
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.