Package net.sf.json

Examples of net.sf.json.JSONObject


    protected String getJavascript() {
        StringBuilder function = new StringBuilder();
       
        function.append(name).append("(");
        if (this.options != null && !this.options.isEmpty()) {
            JSONObject json = JSONObject.fromMap(this.options);
            function.append(json.toString());
        }
        function.append(");");
       
        return function.toString();
    }
View Full Code Here


              .getParameter("categoryAlias"));
          System.out.println("Ok 2");
          if (cate != null) {
            System.out.println(cate.getTitle().getValue());
            if (cate != null) {
              JSONObject object = new JSONObject();
              object.put("categoryAlias", cate.getAlias());
              object.put("thumbImageUrl", cate.getThumbImageUrl()
                  .getValue());
              object.put("count", cate.getCount());
              object.put("subTitle", cate.getSubTitle());
              object.put("description", cate.getDescription()
                  .getValue());
              object.put("listTube", TubeModel.getByCategory(
                  cate.getAlias(), page, 10));
              System.out.println("Get all ok, Category : "
                  + cate.getAlias() + ", page : " + page);
              response.getWriter().write(object.toString());
            }
          }
        }
      }
      // view category.
View Full Code Here

      jsonTxt = "{datasets: [" + jsonTxt + "]}";
    } else if (jsonTxt.startsWith("[")) {
      jsonTxt = "{datasets: " + jsonTxt + "}";
    }
   
    JSONObject json = (JSONObject) JSONSerializer.toJSON(jsonTxt);
    JSONArray  sets = json.getJSONArray("datasets");
   
    Datasets dsets = new Datasets();
    for (int i=0; i < sets.size(); i++) {
      JSONObject set = sets.getJSONObject(i);
      GwtJsonDataset s = new GwtJsonDataset(set);
      Dataset d = datasetReader.createDatasetFromJson(s);
      dsets.add(d);
    }
   
View Full Code Here

  }

  private EventRunner signalEvents(JSONArray jsonResponse) throws JSONException{
    final JSONPacket[] events = new JSONPacket[jsonResponse.size()];
    for(int i=0; i<jsonResponse.size();i++){
      JSONObject jsonEvent = jsonResponse.getJSONObject(i);
      JsonConfig jsonConfig = new JsonConfig();
      jsonConfig.setRootClass( eventTypes.get(jsonEvent.get("type")) );
      try {
        events[i]=(JSONPacket) JSONObject.toBean( jsonEvent, jsonConfig );
      } catch (ClassCastException e) {
        throw new IllegalStateException("Couldn't unmarshall: "+jsonEvent,e);
      }
View Full Code Here

      runner.query(con,sql.toString(), new ResultSetHandler<Object>() {
        public Object handle(ResultSet rs) throws SQLException {
          ResultSetMetaData metaData = rs.getMetaData();
          int cols = metaData.getColumnCount();
          while (rs.next()) {
            JSONObject jsonObj = new JSONObject();
            for (int i = 1; i <= cols; i++) {
              String colName = metaData.getColumnLabel(i);
              String value = rs.getString(colName);
              if (value != null && value.length() != 0) {
                jsonObj.put(colName.toLowerCase(), value);// 列名全部转换成小写,便于前台代码统一处理
              }
            }
            jsonArr.add(jsonObj);
          }
          return jsonArr;
View Full Code Here

    JSONArray arr=CommonDAO.getList(SqlMgr.getSql("GET_30_POSTS"),blockId,blockId,blockId,start,end);
    this.setReqAttr("posts30",arr.toString());
    this.setSessionAttr("blockId", blockId);
   
    //取当前版块的总页数
    JSONObject obj=CommonDAO.getSingle(SqlMgr.getSql("GET_POST_COUNT"), this.blockId);
    if(obj!=null){
      String temp=obj.getString("total");
      if(!StringUtil.isEmpty(temp)){
        this.totalPages=(int) Math.ceil(Float.parseFloat(temp)/postPerPage);
        this.setReqAttr("totalPages", totalPages);
      }
    }
View Full Code Here

    int end=pageIndex*ct;
    JSONArray arr=CommonDAO.getList(SqlMgr.getSql("READ_POST"),postId,postId,start,end);
    System.out.println(arr.toString());
   
    //获取跟帖总页数
    JSONObject obj=CommonDAO.getSingle(SqlMgr.getSql("GET_COMMENT_COUNT"),postId,postId);
    if(obj!=null){
      String temp=obj.getString("total");
      if(!StringUtil.isEmpty(temp)){
        this.totalPages=(int) Math.ceil(Float.parseFloat(temp)/ct);
        this.setReqAttr("totalPages", totalPages);
      }
    }
View Full Code Here

    StringBuffer result=new StringBuffer();
    result.append("<ul id='navigation'>");//注意:此ID和页面脚本绑定,不要更改
    JSONArray roots=CommonDAO.getList(SqlMgr.getSql("GET_FORUM_CHILD_BLOCK"),0);
    if(roots!=null){
      for(int i=0;i<roots.size();i++){
        JSONObject jsonObj=roots.getJSONObject(i);
        String bId=jsonObj.getString("block_id");
        String link=jsonObj.getString("link");
        if(i==0){
          this.blockId=jsonObj.getString("block_id");
        }
        if(link.equals("1")){
          result.append("<li><a id='"+bId+"' href='loadPosts30.action?blockId="+bId+"'>");
        }else{
          result.append("<li><a id='"+bId+"' href='#'>");
        }
       
        result.append(jsonObj.get("block_name"));
        result.append("</a>");
        String blockId=jsonObj.getString("block_id");
       
        JSONArray children=CommonDAO.getList(SqlMgr.getSql("GET_FORUM_CHILD_BLOCK"), blockId);
        if(children!=null&&children.size()!=0){
          result.append("<ul>");
          for(int j=0;j<children.size();j++){
            JSONObject child=children.getJSONObject(j);
            bId=child.getString("block_id");
            link=child.getString("link");
            if(link.equals("1")){
              result.append("<li><a id='"+bId+"' href='loadPosts30.action?blockId="+bId+"'>");
            }else{
              result.append("<li><a id='"+bId+"' href='#'>");
            }
            result.append(child.get("block_name"));
            result.append("</a></li>");
          }
          result.append("</ul></li>");
        }else{
          result.append("</li>");
View Full Code Here

   */
  private void getForumBlocks(){
    JSONArray roots=CommonDAO.getList(SqlMgr.getSql("GET_FORUM_ROOT_BLOCK"));
    this.setSessionAttr("rootBlocks", roots.toString());
   
    JSONObject chObj=new JSONObject();
    for(int i=0;i<roots.size();i++){
      JSONObject obj=roots.getJSONObject(i);
      String bId=obj.getString("block_id");
      JSONArray children=CommonDAO.getList(SqlMgr.getSql("GET_FORUM_CHILD_BLOCK"),bId);
      chObj.put(bId, children.toString());
    }
    this.setSessionAttr("cBlockMap", chObj.toString());
  }
View Full Code Here

  /**
   * 校验用户名是否占用
   * @return
   */
  public String validateUserId(){
    JSONObject result=CommonDAO.getSingle(SqlMgr.getSql("CHECK_USER_ID"), userName);
    if(result!=null){
      this.outJsonString("false");
    }else{
      this.outJsonString("true");
    }
View Full Code Here

TOP

Related Classes of net.sf.json.JSONObject

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.