Package net.sf.json

Examples of net.sf.json.JSONObject.keys()


    private void initEvent(AjaxEvent event, HttpServletRequest request) {
        String paramsString = request.getParameter(this.jsonParamsParameter);
        if (paramsString != null) {
            Map<String, String> parameters = new HashMap<String, String>();
            JSONObject json = JSONObject.fromString(paramsString);
            Iterator keys = json.keys();
            while (keys.hasNext()) {
                String key = keys.next().toString();
                parameters.put(key, json.opt(key).toString());
            }
            event.setParameters(parameters);
View Full Code Here


        {
            final String POST_LENGTH = "POST_LENGTH";
            String requestAsString = new String();
            JSONObject firstLine = json.getJSONObject("firstLine");

            Iterator it = firstLine.keys();
            while (it.hasNext()) {
                requestAsString += (firstLine.get(it.next()));
                if (it.hasNext()) {
                    requestAsString += " ";
                }
View Full Code Here

            int postBegin = requestAsString.length();
            if (json.containsKey(PostData)) {
                JSONObject post = json.getJSONObject(PostData);

                it = post.keys();
                while (it.hasNext()) {
                    String key = (String) it.next();
                    String value = (String) post.get(key);

                    requestAsString += (key + "=" + value);
View Full Code Here

  public void setVariable(String variablestr) {

    if (variablestr != null && variablestr.equals("") == false) {
      JSONObject obj = (JSONObject) JSONSerializer.toJSON(variablestr);
      for (Iterator<?> iter = obj.keys(); iter.hasNext();) {
        String key = (String) iter.next();
        variable.put(key, obj.getString(key));
      }
    }
View Full Code Here

  }

  public void setReplace_time(String replaceTimeStr) {
    if (replaceTimeStr != null && replaceTimeStr.equals("") == false) {
      JSONObject obj = (JSONObject) JSONSerializer.toJSON(replaceTimeStr);
      for (Iterator<?> iter = obj.keys(); iter.hasNext();) {
        String key = (String) iter.next();
        replace_time.put(key, obj.getString(key));
      }
    }
  }
View Full Code Here

  }

  public void setWait_time(String waitTimeStr) {
    if (waitTimeStr != null && waitTimeStr.equals("") == false) {
      JSONObject obj = (JSONObject) JSONSerializer.toJSON(waitTimeStr);
      for (Iterator<?> iter = obj.keys(); iter.hasNext();) {
        String key = (String) iter.next();
        if (key.trim().equalsIgnoreCase("before")) {
          String time = obj.getString(key);
          if (time==null||time.trim().length()==0) {
            this.before_wait_time = 0;
View Full Code Here

  private  static HashMap<String, String> GetJSONASString(String jsonStr){
    HashMap<String, String> hashMap=null;
    hashMap=new HashMap<String, String>();
    if(JudgeStringJson(jsonStr)==BJSON.ObjectJson){
      JSONObject jsonObject=JSONObject.fromObject(jsonStr);
      Iterator<String> it=jsonObject.keys();
      while(it.hasNext()){
        String key=it.next();
        String value=jsonObject.get(key).toString();
        hashMap.put(key, value);
      }
View Full Code Here

    Iterator it = jsonArray.iterator();
    while (it.hasNext()) {
      JSONObject jsonObject = (JSONObject) it.next();

      Iterator keys = jsonObject.keys();
      while (keys.hasNext()) {
        Object key = keys.next();
        Object value = jsonObject.get(key);
        arrayList.add(value);
      }
View Full Code Here

   * @return
   */
  public static HashMap toHashMap(Object object) {
    HashMap<String, Object> data = new HashMap<String, Object>();
    JSONObject jsonObject = JSONHelper.toJSONObject(object);
    Iterator it = jsonObject.keys();
    while (it.hasNext()) {
      String key = String.valueOf(it.next());
      Object value = jsonObject.get(key);
      data.put(key, value);
    }
View Full Code Here

    List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
    JSONArray jsonArray = JSONArray.fromObject(object);
    for (Object obj : jsonArray) {
      JSONObject jsonObject = (JSONObject) obj;
      Map<String, Object> map = new HashMap<String, Object>();
      Iterator it = jsonObject.keys();
      while (it.hasNext()) {
        String key = (String) it.next();
        Object value = jsonObject.get(key);
        map.put((String) key, value);
      }
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.