Package net.sf.json

Examples of net.sf.json.JSONArray


        int len = 0;
        while ((len = in.read(buffer)) > 0) {
            sb.append(buffer, 0, len);
        }
        if (target != null && sb.length() > 0 && sb.charAt(0) == '[') {
            JSONArray jsonArray = JSONArray.fromObject(sb.toString());
            if (target.getClass().isArray()) {
                JSONArray.toArray(jsonArray, target, new JsonConfig());
            } else {
                JSONArray.toList(jsonArray, target, new JsonConfig());
            }
View Full Code Here


    }

    public String fromObject(Object obj, String resultCode, Writer stream) throws IOException {
        if (obj != null) {
            if (isArray(obj)) {
                JSONArray jsonArray = JSONArray.fromObject(obj);
                stream.write(jsonArray.toString());
            } else {
                JSONObject jsonObject = JSONObject.fromObject(obj);
                stream.write(jsonObject.toString());
            }
        }
View Full Code Here

        e.printStackTrace();
      }
    String users=(String) properties.get("user");
    System.err.println("jsonString:"+users);
   
    JSONArray ja = JSONArray.fromObject(jsonString);
    Map<String, Class<?>> classMap = new HashMap<String, Class<?>>();
    classMap.put("list", domain);
      List<?> list = JSONArray.toList(ja, User.class,classMap);
      return list;
  }
View Full Code Here

        fieldSet.add(searchFields[i]);
      }
    }

    // add the documents from search hits
    JSONArray docsAr = new JSONArray();
    HitDetails[] details = results.getDetails();
    Hit[] hits = results.getHits();
    Summary[] summaries = results.getSummaries();
    for (int i = 0; i < details.length; i++) {
     
      // every document has an indexno and an indexdocno
      JSONObject result = new JSONObject();
      HitDetails detail = details[i];
      Hit hit = hits[i];
      result.accumulate("indexno", hit.getIndexNo());
      result.accumulate("indexkey", hit.getUniqueKey());
     
      // don't add summaries not including summaries
      if (summaries != null && results.isWithSummary()) {
        Summary summary = summaries[i];
        result.accumulate("summary", summary.toString());
      }
     
      // add the fields from hit details
      JSONObject fields = new JSONObject();
      for (int k = 0; k < detail.getLength(); k++) {
        String name = detail.getField(k);
        String[] values = detail.getValues(name);
       
        // if we specified fields to return, only return those fields
        if (fieldSet.size() == 0 || fieldSet.contains(name)) {
          JSONArray valuesAr = new JSONArray();
          for (int m = 0; m < values.length; m++) {
            valuesAr.add(values[m]);
          }
          fields.accumulate(name, valuesAr);
        }
      }
      result.accumulate("fields", fields);
View Full Code Here

        }
       
        //********************************
       
        // Third generate a JSONObject object containts JSONArray
        JSONArray coursesListJSONArray = JSONArray.fromObject(coursesMapList);
        JSONObject respondJSONObject = new JSONObject();
        respondJSONObject.element("recommendedCoursesList", coursesListJSONArray);
       
        try {
            /* TODO output your page here. You may use following sample code. */
 
View Full Code Here

        }
       
        //********************************
       
        // Third generate a JSONObject object containts JSONArray
        JSONArray coursesListJSONArray = JSONArray.fromObject(coursesMapList);
        JSONObject respondJSONObject = new JSONObject();
        respondJSONObject.element("searchedCoursesList", coursesListJSONArray);
       
        try {
            /* TODO output your page here. You may use following sample code. */
 
View Full Code Here

        }
       
        //********************************
       
        // Forth generate a JSONObject object containts JSONArray
        JSONArray coursesListJSONArray = JSONArray.fromObject(coursesMapList);
        JSONObject respondJSONObject = new JSONObject();
        respondJSONObject.element("myCoursesList", coursesListJSONArray);
       
        try {
            /* TODO output your page here. You may use following sample code. */
 
View Full Code Here

        }

        //********************************
       
        // Forth generate a JSONObject object containts JSONArray
        JSONArray commentsListJSONArray = JSONArray.fromObject(commentMapList);
        JSONObject respondJSONObject = new JSONObject();
        respondJSONObject.element("courseCommentsList", commentsListJSONArray);

        try {
            /* TODO output your page here. You may use following sample code. */
 
View Full Code Here

      maxY = y;
    }
  }
 
  public JSONArray asJSONArray() {
    JSONArray bbox = null;

    if( null != minX
     && null != minY
     && null != maxX
     && null != maxY ) {
      bbox = new JSONArray();
 
      bbox.add(minX);
      bbox.add(minY);
      bbox.add(maxX);
      bbox.add(maxY);
    }
   
    return bbox;
  }
View Full Code Here

      } else {
        layerDef.put("name", "GPX");
      }
     
      GpxBounds bounds = context.getLayerBounds();
      JSONArray bbox = null;
      if( null != bounds ) {
        bbox = bounds.asJSONArray();
      }
      if( null != bbox ) {
        layerDef.put("bbox", bbox);
View Full Code Here

TOP

Related Classes of net.sf.json.JSONArray

Copyright © 2018 www.massapicom. 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.