Examples of JSONObject


Examples of ar.com.restba.json.JsonObject

      while (i.hasNext()) {
        Map.Entry<Object, Object> e = i.next();
        if (isStandardProperty(e.getValue().getClass())) {
          this.map.put(e.getKey(), e.getValue());
        } else {
          this.map.put(e.getKey(), new JsonObject(e.getValue(), includeSuperClass));
        }
      }
    }
  }
View Full Code Here

Examples of bgu.bio.io.file.json.JSONObject

  }

  @Override
  public boolean isEnd(String msg) {
    try {
      JSONObject obj = new JSONObject(msg);
      String command = obj.getString("command");
      return command.equals("terminate");
    } catch (JSONException ex) {
      ex.printStackTrace();
    }
    return false;
View Full Code Here

Examples of blackberry.common.util.json4j.JSONObject

    public void invoke( JSExtensionRequest request, JSExtensionResponse response ) throws WidgetException {
        String method = request.getMethodName();
        Object[] args = request.getArgs();
        String msg = "";
        int code = JSExtensionReturnValue.SUCCESS;
        JSONObject data = new JSONObject();
        JSONObject returnValue = null;
       
        try {
            if( method.equals( SETUP ) ) {
                if (args != null && args.length == 3)
                {
                    setupLogging(args[0].toString(), args[1].toString(), Integer.parseInt(args[2].toString()));
                }
                else
                {
                    writeToLog("webworks.system.log", "WebWorks System Log API", "ERROR 4419 Improper API useage");
                }
           
                               
            } else if( method.equals( WRITE ) ) {
                             
                if (args != null && args.length == 1)
                {
                    writeToLog(args[0].toString());
                } else if (args != null && args.length == 3)
                {
                    writeToLog(args[0].toString(), args[1].toString(), args[2].toString());
                }
                else
                {
                    writeToLog("blackberry.system.log", "WebWorks System Log API", "ERROR 4419 Improper API useage");
               
                        }
        } catch( Exception e ) {
            msg = e.getMessage();
            code = JSExtensionReturnValue.FAIL;
        }

        returnValue = new JSExtensionReturnValue( msg, code, data ).getReturnValue();

        response.setPostData( returnValue.toString().getBytes() );
    }
View Full Code Here

Examples of ch.bfh.sokoban.lib.jsonJava.JSONObject

  /**
   * Add the database options for the php - file to a nameValuePair
   */
  private static void addOptions(Options options)
  {
    jsonObject = new JSONObject();
    jsonArray = new JSONArray();

    try
    {
      jsonObject.put("query", options.getSql());
View Full Code Here

Examples of com.addthis.maljson.JSONObject

            return encodeArray(object);
        }
        if (object instanceof JSONCodable) {
            return ((JSONCodable) object).toJSONObject();
        }
        JSONObject obj = null;
        boolean lock = object instanceof Codec.ConcurrentCodable;
        if (lock && !((Codec.ConcurrentCodable) object).encodeLock()) {
            throw new Exception("Unable to acquire encoding lock on " + object);
        }
        try {
            if (object instanceof SuperCodable) {
                ((SuperCodable) object).preEncode();
            }
            CodableClassInfo classInfo = getClassFieldMap(object.getClass());
            if (classInfo.size() == 0 && !(object instanceof Codable)) {
                return object;
            }
            obj = new JSONObject();
            String altType = classInfo.getClassName(object);
            if (altType != null) {
                obj.put(classInfo.getClassField(), altType);
            }
            for (Iterator<CodableFieldInfo> fields = classInfo.values().iterator(); fields.hasNext();) {
                CodableFieldInfo field = fields.next();
                Object value = field.get(object);
                if (value == null || value == JSONObject.NULL || field.isReadOnly()) {
                    continue;
                }
                if (CodecJSON.JSONCodable.class.isAssignableFrom(field.getType())) {
                    value = ((CodecJSON.JSONCodable) value).toJSONObject();
                    obj.put(field.getName(), value);
                } else if (field.isArray()) {
                    obj.put(field.getName(), encodeArray(value));
                } else if (field.isMap()) {
                    Map<?, ?> map = (Map<?, ?>) value;
                    JSONObject jmap = new JSONObject();
                    for (Entry<?, ?> entry : map.entrySet()) {
                        Object mval = entry.getValue();
                        // TODO fails with null keys
                        jmap.put(entry.getKey().toString(), encodeObject(mval));
                    }
                    obj.put(field.getName(), jmap);
                } else if (field.isCollection()) {
                    JSONArray jarr = new JSONArray();
                    for (Iterator<?> iter = ((Collection<?>) value).iterator(); iter.hasNext();) {
View Full Code Here

Examples of com.alibaba.fastjson.JSONObject

                    }
                }
            }

            if (clazz.isInterface()) {
                JSONObject object;

                if (map instanceof JSONObject) {
                    object = (JSONObject) map;
                } else {
                    object = new JSONObject(map);
                }

                return (T) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
                                                  new Class<?>[] { clazz }, object);
            }
View Full Code Here

Examples of com.alimama.mdrill.json.JSONObject

      String uuuuid=uuid.trim().replaceAll("\t", "");
      if(uuuuid.isEmpty())
      {
        continue;
      }
      JSONObject info=readAbtestInfo(uuuuid);
      LOG.info(uuid+">>"+info.toString());
      if(String.valueOf(info.get("code")).equals("1"))
      {
        exlist.add(String.valueOf(info.getJSONObject("data").get("A")));
        exlist.add(String.valueOf(info.getJSONObject("data").get("B")));
       
      }
    }
   
   
    String[] number_important=Json2Array(number_important_json);
    String[] colls_important=Json2Array(colls_important_json);
    String[] colls=Json2Array(colls_json);
    String[] numbers=Json2Array(numbers_json);
   
    long t1 = System.currentTimeMillis();
 
    Map stormconf = Utils.readStormConfig();
   
    hivePartion hp=getPartion(stormconf, projectName);
    boolean isPartionByPt=hp.isPartionByPt;
    String hpart=hp.hpart;
    projectName=hp.projectName;

    String mode=String.valueOf(stormconf.get("higo.mode."+projectName));

    queryStr = WebServiceParams.query(queryStr);


    TablePartion part = GetPartions.partion(projectName);
    KmeansQueryParse kmeansData = AdhocHivePartions.getKmeansDays(queryStr);
   
    LinkedHashMap<String, String> filetypeMap = MdrillFieldInfo.readFieldsFromSchemaXml(stormconf,part.name);
    ArrayList<String> fqList = WebServiceParams.fqListHive(false,hpart,kmeansData.queryStr,isPartionByPt, filetypeMap,null,null,null);
   
    StringBuffer sqlWhere =AdhocWebServiceParams.makeWhere(fqList,exlist,idcols);
    LOG.info("queryStr:"+queryStr+">>>>kmeansData.queryStr:"+kmeansData.queryStr+","+sqlWhere.toString()+","+fqList.toString());

 
//    String hql = "select custid from " + projectName + " " + sqlWhere.toString() + " " ;
    final String[] sqlparams=PrintSql.makeSql(projectName, sqlWhere.toString(), idcols, kmeansData.getSortDays(), colls_important, number_important, colls, numbers);;
    String hql=sqlparams[0];
   
    String md5 = MD5.getMD5(hql);
 
    SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd");
    String day = fmt.format(new Date());
 
    final String hdpConf = (String) stormconf.get("hadoop.conf.dir");
    String connstr = (String) stormconf.get("higo.download.offline.conn");
    String uname = (String) stormconf.get("higo.download.offline.username");
    String passwd = (String) stormconf.get("higo.download.offline.passwd");
    final String store = (String) stormconf.get("higo.download.offline.store")+ "/" + day + "/" + java.util.UUID.randomUUID().toString();
    MySqlConn conn = new MySqlConn(connstr, uname, passwd);
    MysqlInfo info = new MysqlInfo(conn);
    if (username == null || username.length() <= 0) {
      username = "default";
    }
 
    StringBuffer sqlbuff = new StringBuffer();
    sqlbuff.append(";");
    int size = info.getUser(username, true, sqlbuff).size();
    JSONObject jsonObj = new JSONObject();
    jsonObj.put("sqlbuff", sqlbuff.toString());
    jsonObj.put("size", size);

    final String storepath=store+"/abtest/cluster_abtest";
    if (size < 5) {
      final MysqlCallbackKmeans callback = new MysqlCallbackKmeans(conn);
     
      Runnable process=new Runnable() {
       
        @Override
        public void run() {
          Configuration conf=new Configuration();
           HadoopBaseUtils.grabConfiguration(hdpConf, conf);
          try {
            ToolRunner.run(conf, new KMeansDriver(callback), new String[]{
              ""
              ,store+"/hive"
              ,store+"/abtest"
              ,"20"
              ,"1000" //k
              ,"0.00001" //delta
              ,String.valueOf(count)
              ,String.valueOf(rep)
              ,String.valueOf(100)
              ,sqlparams[1]
              ,String.valueOf(548576)
            });
           
            makeAB(storepath, conf);

          } catch (Exception e) {
            throw new RuntimeException(e);
          }
         
        }
      };
      callback.setCols("");
      OfflineDownload download = new OfflineDownload();
      download.setOffline(callback);
      if (mailto == null || mailto.length() <= 0) {
        mailto = "yannian.mu@alipay.com";
      }
     
      download.setMailto(mailto);
      download.setHql(" INSERT OVERWRITE DIRECTORY '" + store+"/hive" + "' " + hql+"  ");
      download.setUseName(username);
      if (jobname == null || jobname.length() <= 0) {
        jobname = day + "_" + md5;
      }
      download.setJobName(jobname);
      download.setMemo(String.valueOf(memo));
      download.setDisplayParams(params);
      download.setStoreDir(storepath);
      download.setConfdir(hdpConf);
      download.setSqlMd5(md5);
      download.setProcesser(process);
      download.run();
 
      long t2 = System.currentTimeMillis();
      jsonObj.put("code", "1");
 
      jsonObj.put("message","数据下载中...完成后将会通过<b style=\"color:red\">旺旺</b>和<b style=\"color:red\">邮件</b>通知");
      jsonObj.put("uuid", callback.getUuid());
      jsonObj.put("debug", callback.toString());
      jsonObj.put("timedebug", String.valueOf(t2 - t1));
 
    } else {
      jsonObj.put("code", "0");
      jsonObj.put("message", "还有" + size + "个任务没有完成数据下载,请稍后提交");
    }
 
    if (jsoncallback != null && jsoncallback.length() > 0) {
      return jsoncallback + "(" + jsonObj.toString() + ")";
    } else {
      return jsonObj.toString();
    }
 
 
  }
View Full Code Here

Examples of com.amazonaws.util.json.JSONObject

                try {
                    // String credentialsResponse = new
                    // EC2MetadataClient().getDefaultCredentials();
                    String credentialsResponse = getDefaultCredentials();

                    JSONObject jsonObject = new JSONObject(credentialsResponse);

                    if (jsonObject.has("Token")) {
                        credentials = new BasicSessionCredentials(jsonObject.getString("AccessKeyId"),
                                jsonObject.getString("SecretAccessKey"), jsonObject.getString("Token"));
                    } else {
                        credentials = new BasicAWSCredentials(jsonObject.getString("AccessKeyId"),
                                jsonObject.getString("SecretAccessKey"));
                    }

                    if (jsonObject.has("Expiration")) {
                        /*
                         * TODO: The expiration string comes in a different
                         * format than what we deal with in other parts of the
                         * SDK, so we have to convert it to the ISO8601 syntax
                         * we expect.
                         */
                        String expiration = jsonObject.getString("Expiration");
                        expiration = expiration.replaceAll("\\+0000$", "Z");

                        credentialsExpiration = new DateUtils().parseIso8601Date(expiration);
                    }
                } catch (IOException e) {
View Full Code Here

Examples of com.baidu.gson.JsonObject

   * @throws Exception
   */
  @Deprecated
  protected Object parseResult(int id, JsonElement ele, Method method)
      throws Exception {
    JsonObject res = (JsonObject) ele;
    if (!res.get("jsonrpc").getAsString().equals("2.0")) {
      throw new InternalErrorException();
    }
    JsonElement result = res.get("result");
    if (result != null) {
      if (res.get("id").getAsInt() != id) {
        throw new InternalErrorException("no id in response");
      } else {
        return gson.fromJson(result, method.getGenericReturnType());
      }
    } else {
      JsonElement e = res.get("error");
      if (e != null) {
        JsonRpcException jre = exceptionHandler.deserialize(e);
        if (jre instanceof ServerErrorException) {
          String msg = jre.getMessage();
          Class<?>[] exp_types = method.getExceptionTypes();
View Full Code Here

Examples of com.bj58.sfft.json.orgjson.JSONObject

      junit.framework.Assert.assertEquals(expected, actual);
    }

    TestEntity te = TestEntity.createInstrance();
    String jsonStr = JsonHelper.toJsonExt(te);
    JSONObject jsonObj = new JSONObject(jsonStr);

    Byte actual = new JsonConvert().convertToByte(jsonObj.get("fByte"));
    junit.framework.Assert.assertEquals(te.getFByte(), actual);
  }
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.