Package org.json

Examples of org.json.JSONObject.optJSONObject()


    JSONObject responseJson = new JSONObject(response);

    Iterator keys = responseJson.keys();
    while (keys.hasNext()) {
      String key = (String) keys.next();
      ret.put(Long.parseLong(key), responseJson.optJSONObject(key));
    }

    return ret;
  }
    public String getSearchUrl() {
View Full Code Here


        ",\"facets\":{    \"object_properties\":{\"minHit\":1, \"max\":100, \"properties\":{\"maxFacetsPerKey\":1} }}" +
        "}";
    //assertEquals(broker.browse(new SenseiRequest()).getNumHits(), 15000);
    JSONObject res = search(new JSONObject(req));
    assertEquals("numhits is wrong", 8180, res.getInt("numhits"));
    assertTrue(res.optJSONObject("facets").optJSONArray("object_properties").length() < 10);
    req = "{\"selections\":[{\"terms\":{\"object_properties\":{\"values\":[\"key1\"],\"operator\":\"or\"," +
        "}}}]" +
        ",\"facets\":{    \"object_properties\":{\"minHit\":1, \"max\":100, \"properties\":{\"maxFacetsPerKey\":10} }}" +
        "}";
    //assertEquals(broker.browse(new SenseiRequest()).getNumHits(), 15000);
View Full Code Here

        ",\"facets\":{    \"object_properties\":{\"minHit\":1, \"max\":100, \"properties\":{\"maxFacetsPerKey\":10} }}" +
        "}";
    //assertEquals(broker.browse(new SenseiRequest()).getNumHits(), 15000);
    res = search(new JSONObject(req));
    System.out.println(res.toString(1));
    assertTrue(res.optJSONObject("facets").optJSONArray("object_properties").length() > 10);
  }
  public void test4TotalCountWithFacetSpecLimitMaxFacetsPerKey() throws Exception
  {
    logger.info("executing test case testTotalCountWithFacetSpec");
    SenseiRequest req = new SenseiRequest();
View Full Code Here

    {
      JSONObject info = array.getJSONObject(i);
      SenseiSystemInfo.SenseiFacetInfo facetInfo =
        new SenseiSystemInfo.SenseiFacetInfo(info.getString(SenseiSearchServletParams.PARAM_SYSINFO_FACETS_NAME));
      facetInfo.setRunTime(info.optBoolean(SenseiSearchServletParams.PARAM_SYSINFO_FACETS_RUNTIME));
      facetInfo.setProps(convertJsonToStringMap(info.optJSONObject(SenseiSearchServletParams.PARAM_SYSINFO_FACETS_PROPS)));

      infos.add(facetInfo);
    }

    return infos;
View Full Code Here

        }
        else if (SenseiSearchServletParams.PARAM_RESULT_HIT_GROUPHITSCOUNT.equals(key)){
          hit.setGroupHitsCount(hitObj.getInt(SenseiSearchServletParams.PARAM_RESULT_HIT_GROUPHITSCOUNT));
        }
        else if (SenseiSearchServletParams.PARAM_RESULT_HIT_EXPLANATION.equals(key)){
          hit.setExplanation(convertToExplanation(hitObj.optJSONObject(SenseiSearchServletParams.PARAM_RESULT_HIT_EXPLANATION)));
        }
        else if (SenseiSearchServletParams.PARAM_RESULT_HIT_GROUPHITS.equals(key)) {
          hit.setGroupHits(convertHitsArray(hitObj.getJSONArray(SenseiSearchServletParams.PARAM_RESULT_HIT_GROUPHITS)));
        }
        else {
View Full Code Here

      //map reduce
      JSONObject mapReduceJson =  json.optJSONObject(RequestConverter2.MAP_REDUCE);
      if (mapReduceJson != null) {
        String key = mapReduceJson.getString(MAP_REDUCE_FUNCTION);
        SenseiMapReduce senseiMapReduce = MapReduceRegistry.get(key);
        senseiMapReduce.init(mapReduceJson.optJSONObject(MAP_REDUCE_PARAMETERS));
        req.setMapReduceFunction(senseiMapReduce);
      }
     // facets
      JSONObject facets = json.optJSONObject(RequestConverter2.FACETS);
      if (facets!=null){
View Full Code Here

        argumentsType.put(argIndex, arrayClass);
      }
      else if (objectType.equals(TYPE_QUERY)) {
        objectValue = (String) argInfo.get(VALUE);
        JSONObject qTmp = new JSONObject(objectValue);
        qTmp = qTmp.optJSONObject(TYPE_QUERY).optJSONObject(BooleanQueryConstructor.QUERY_TYPE);
        QueryConstructor queryConstructor =
            QueryConstructor.getQueryConstructor(BooleanQueryConstructor.QUERY_TYPE, queryParser);
        Query baseQuery = queryConstructor.doConstructQuery(qTmp);
        arguments.put(argIndex, baseQuery);
        argumentsType.put(argIndex, Query.class);
View Full Code Here

            JSONObject props;
            Collection<String> keys;
            if (!r.isStreamed()) {
                JSONObject json = new JSONObject(r.getBody());
                JSONArray jsonKeys = json.optJSONArray(Constants.FL_KEYS);
                props = json.optJSONObject(Constants.FL_SCHEMA);
                keys = ClientUtils.jsonArrayAsList(jsonKeys);
            } else {
                InputStream stream = r.getStream();
                JSONTokener tokens = new JSONTokener(new InputStreamReader(stream));
View Full Code Here

            JSONObject props;
            Collection<String> keys;
            if (!r.isStreamed()) {
                JSONObject json = new JSONObject(r.getBodyAsString());
                JSONArray jsonKeys = json.optJSONArray(Constants.FL_KEYS);
                props = json.optJSONObject(Constants.FL_SCHEMA);
                keys = ClientUtils.jsonArrayAsList(jsonKeys);
            } else {
                InputStream stream = r.getStream();
                JSONTokener tokens = new JSONTokener(new InputStreamReader(stream));
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.