Package com.alimama.mdrill.json

Examples of com.alimama.mdrill.json.JSONArray


    {
      return -1l;
    }
    Long total=jsonObj.getLong("total");
    JSONObject data=jsonObj.getJSONObject("data");
    JSONArray list=data.getJSONArray("docs");
    for(int i=0;i<list.length();i++)
    {
      JSONObject rowMap=list.getJSONObject(i);
      ArrayList<Object> row=new ArrayList<Object>();
      for(int j=0;j<this.parser.colsNames.length;j++)
      {
        String colname=this.parser.colsNames[j];
        row.add(j, String.valueOf(rowMap.opt(colname)));
View Full Code Here


         item.put(fl[i], String.valueOf(vv.getValue()));
       }
     }
   
   
        JSONArray list=new JSONArray();
        list.put(item);

        this.jsons=list.toString();
 
  }
View Full Code Here


  }
  public static String insert(String projectName,String list,ShardsList[] coresfortest)
      throws Exception {
    JSONArray jsonStr=new JSONArray(list.trim());
      Collection<SolrInputDocument> docs = new ArrayList<SolrInputDocument>();

    for(int i=0;i<jsonStr.length();i++)
    {
      SolrInputDocument doc=new SolrInputDocument();
      JSONObject obj=jsonStr.getJSONObject(i);
      Iterator keys = obj.keys();
      while (keys.hasNext()) {
        String key = (String) keys.next();
        doc.addField(key, obj.get(key));
      }
View Full Code Here

    }
   
   
    if(jsonObj.getString("code").equals("1")&&req.sortType.isStatNum)
    {
      JSONArray jsonArray=jsonObj.getJSONObject("data").getJSONArray("docs");
      ArrayList<JSONObject> results=new ArrayList<JSONObject>();
      boolean iscontains=true;
      for(int i=0;i<jsonArray.length();i++)
      {
        JSONObject obj=jsonArray.getJSONObject(i);
        if(!obj.has(req.sortType.sortRow))
        {
          iscontains=false;
        }
        results.add(obj);
      }
      final boolean isdesc=req.sortType.order.toLowerCase().equals("true");
      boolean needsort=jsonObj.getLong("total")>(UniqConfig.defaultCrossMaxLimit()-10);
      if(iscontains&&needsort)
      {
        Collections.sort(results, new Comparator<JSONObject>() {
          @Override
          public int compare(JSONObject o1, JSONObject o2) {
            int rtn=0;
            try {
              rtn = Double.compare(ParseDouble(o1.get(req.sortType.sortRow)), ParseDouble(o2.get(req.sortType.sortRow)));
            } catch (JSONException e) {
            }
            if(isdesc)
            {
              rtn*=-1;
            }
            return rtn;
          }
        }
        );
      }
     
      JSONArray rtnarr=new JSONArray();
      int actualstart=req.start-slimit.start;
      int actualend=req.rows+actualstart;
      for(int i=actualstart;i<results.size()&&i<actualend;i++)
      {
        rtnarr.put(results.get(i));
      }
     
      jsonObj.getJSONObject("data").put("docs", rtnarr);
    }
  }
View Full Code Here

          minValue = value;
        }
      }


      JSONArray jsonArray=new JSONArray();

      int total=0;
      if(fcsize>0)
      {
        int start = WebServiceParams.parseStart(startStr);
        int rows = WebServiceParams.parseRows(rowsStr);
        SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd");
        Date d1=fmt.parse(String.valueOf(maxValue));
        Date d2=fmt.parse(String.valueOf(minValue));
       
        total = ((int) (d1.getTime() / 1000) - (int) (d2.getTime() / 1000)) / 3600 / 24+1
       
        for(int i=start;i<(start+rows)&&i<total;i++)
        {
          jsonArray.put(fmt.format(new Date(d1.getTime()-i*1000l*3600*24)));
        }
      }
   
     
      JSONObject jsonObj = new JSONObject();
View Full Code Here

  {
    if(leftjoin==null||leftjoin.trim().isEmpty())
    {
      return new HigoAdhocJoinParams[0];
    }
    JSONArray jsonStr=new JSONArray(leftjoin.trim());
    HigoAdhocJoinParams[] rtn=new HigoAdhocJoinParams[jsonStr.length()];
    for(int i=0;i<jsonStr.length();i++)
    {
      JSONObject obj=jsonStr.getJSONObject(i);
      HigoAdhocJoinParams p=new HigoAdhocJoinParams();
      p.tablename=obj.getString("tablename");
     
      HashMap<String, String> map=TableJoin.getTableInfo(p.tablename);
      if(map!=null)
View Full Code Here

  {
    JSONObject jsonObj = new JSONObject();
    jsonObj.put("code", 1);
    jsonObj.put("message", "success");
   
    JSONArray modules = new JSONArray();
   
   
    HashMap<String,JSONObject> tableInfo=new HashMap<String, JSONObject>();
//    {
//      "moduleName": "P4P-推广",
View Full Code Here

  {
    ArmoryInfo info=getInfo(name);
    JSONObject jsonObj = new JSONObject();
    jsonObj.put("code", "1");
    JSONObject jsonObj2 = new JSONObject();
    JSONArray jsonArray = new JSONArray();

    for(ArmoryItemInfo i:info.info)
    {
      jsonArray.put(i.tomap());
    }
    jsonObj2.put("docs", jsonArray);

    jsonObj.put("data", jsonObj2);
View Full Code Here

  }
 
  public static void addJsonList(String json,String user) throws Exception
  {
    JSONObject jsonObj = new JSONObject(json);
    JSONArray list=jsonObj.getJSONObject("data").getJSONArray("users");
    for(int i=0;i<list.length();i++)
    {
      JSONObject obj=list.getJSONObject(i);
      addjson(obj.toString(),user);
    }
  }
View Full Code Here

    Connection conn = m_fpsql.getConn();
    Statement stmt = conn.createStatement();
    try {
      ResultSet res = stmt.executeQuery(strSql);
      JSONArray userlist=new JSONArray();
      while (res.next()) {
        JSONObject item = new JSONObject();
        item.put("userid", String.valueOf(res.getString("userid")));
        item.put("email", String.valueOf(res.getString("email")));
        item.put("queryday", String.valueOf(res.getString("queryday")));

       
        item.put("cname", String.valueOf(res.getString("cname")));

        item.put("role", Integer.parseInt(res.getString("role")));
        item.put("permission", new JSONArray(res.getString("permission")));
        item.put("opuser", String.valueOf(res.getString("opuser")));
        item.put("optime", String.valueOf(res.getString("optime")));


        userlist.put(item);
       }
      m_fpsql.close();
      jsonObj.put("code", "1");
      jsonObj.put("message", "success");
      JSONObject dddd = new JSONObject();
View Full Code Here

TOP

Related Classes of com.alimama.mdrill.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.