Package net.sf.json

Examples of net.sf.json.JSONArray


    }else if(result!=null){
      //更新用户状态为已登录,并更新IP地址、记录最后登录时间
      String ipAddr=this.getIpAddr();
      CommonDAO.update(SqlMgr.getSql("USER_LOGIN"),ipAddr,userName);
      //加载用户的权限代码
      JSONArray permissions=CommonDAO.getList(SqlMgr.getSql("GET_USER_PERMISSION"),userName);
      if(permissions!=null){
        Iterator<JSONObject> iter=permissions.iterator();
        while(iter.hasNext()){
          JSONObject jsonObj=iter.next();
          this.setSessionAttr(jsonObj.getString("permission_code"), jsonObj.getString("permission_desc"));
        }
      }
View Full Code Here


  /**
   * 获取所有行业列表
   * @return
   */
  public String getIndustry(){
    JSONArray depts=CommonDAO.getList(SqlMgr.getSql("GET_INDUSTY"));
    System.out.println(depts.toString());
    this.outJsonString(depts.toString());
    return null;
  }
View Full Code Here

   * @param o
   * @param isInjectDefaultConvertHandler 是否注入默认对象转换类
   */
  public void outJsonObject(Object o,boolean isInjectDefaultConvertHandler){
    if(Collection.class.isInstance(o)||o.getClass().isArray()){
      JSONArray ja=null;
      if(isInjectDefaultConvertHandler){
        ja=JSONArray.fromObject(o,getJsonConfig(null));
      }else{
        ja=JSONArray.fromObject(o);
      }
      this.outJsonString(ja.toString());
    }else{
      JSONObject jo=null;
      if(isInjectDefaultConvertHandler){
        jo=JSONObject.fromObject(o,getJsonConfig(null));
      }else{
View Full Code Here

        Locale locale = request.getLocale();
        if(!uiLabelObject.isEmpty()) {
            Set<String> resourceSet = UtilGenerics.checkSet(uiLabelObject.keySet());
            // Iterate over the resouce set
            for (String resource : resourceSet) {
                JSONArray labels = uiLabelObject.getJSONArray(resource);
                if (labels.isEmpty() || labels == null) {
                    continue;
                }

                // Iterate over the uiLabel List
                Iterator<String> jsonLabelIterator = UtilGenerics.cast(labels.iterator());
                JSONArray resourceLabelList = new JSONArray();
                while(jsonLabelIterator.hasNext()) {
                    String label = jsonLabelIterator.next();
                    String receivedLabel = UtilProperties.getMessage(resource, label, locale);
                    if (UtilValidate.isNotEmpty(receivedLabel)) {
                        resourceLabelList.add(receivedLabel);
                    }
                }
                jsonUiLabel.element(resource, resourceLabelList);
            }
        }
View Full Code Here

            uiLabelObject = new JSONObject();
            // Transform JSON String to Object
            uiLabelObject = (JSONObject) JSONSerializer.toJSON(requiredLabels);
        }

        JSONArray jsonUiLabel = new JSONArray();
        Locale locale = request.getLocale();
        if(!uiLabelObject.isEmpty()) {
            Set<String> resourceSet = UtilGenerics.checkSet(uiLabelObject.keySet());
            // Iterate over the resource set
            // here we need a keySet because we don't now which label resource to load
            // the key set should have the size one, if greater or empty error should returned
            if (UtilValidate.isEmpty(resourceSet)) {
                Debug.logError("No resource and labels found", module);
                return "error";
            } else if (resourceSet.size() > 1) {
                Debug.logError("More than one resource found, please use the method: getJSONuiLabelArray", module);
                return "error";
            }

            for (String resource : resourceSet) {
                String label = uiLabelObject.getString(resource);
                if (UtilValidate.isEmail(label)) {
                    continue;
                }

                String receivedLabel = UtilProperties.getMessage(resource, label, locale);
                jsonUiLabel.add(receivedLabel);
            }
        }

        writeJSONtoResponse(jsonUiLabel, request.getMethod(), response);
        return "success";
View Full Code Here

      if (statusCode != HttpStatus.SC_OK) {
        log.error("Request failed: " + method.getStatusLine());
      }

      JSONObject json = (JSONObject) JSONSerializer.toJSON(method.getResponseBodyAsString());
      JSONArray arr = json.getJSONArray("results");
      for (Object o : arr) {
        JSONObject item = (JSONObject) o;
        CRResolvableBean bean = createBean(item);
        resultlist.add(bean);
      }
View Full Code Here

      // No Data Found
      throw new CRException("NoDataFound", "Data could not be found.", ERRORTYPE.NO_DATA_FOUND);
    } else {
      this.rootObject.element("status", "ok");

      JSONArray jsArray = new JSONArray();

      for (Iterator<CRResolvableBean> it = this.resolvableColl.iterator(); it.hasNext();) {

        CRResolvableBean crBean = it.next();

        JSONObject objElement = processElement(crBean);

        jsArray.add(objElement);

      }
      this.rootObject.element("Objects", jsArray);
    }
View Full Code Here

        Object bValue = crBean.getAttrMap().get(entry);

        if (bValue != null) {
          // deal with multivalue attributes
          if ((bValue.getClass().isArray() && !(bValue instanceof byte[])) || bValue instanceof List) {
            JSONArray value = new JSONArray();
            List<Object> arr;
            if (bValue instanceof List) {
              arr = new ArrayList<Object>();
              List<Object> ob_arr = (List<Object>) bValue;
              for (Object obj : ob_arr) {
                String v = "";
                v = convertToString(obj);
                arr.add(v);
              }
            } else {
              arr = new ArrayList<Object>();
              Object[] ob_arr = (Object[]) bValue;
              for (Object obj : ob_arr) {
                String v = "";
                v = convertToString(obj);
                arr.add(v);
              }
            }
            value.addAll(arr);
            attrContainer.element(entry, value);
          } else if (bValue instanceof Map<?, ?>) {
            attrContainer.element(entry, bValue);
          }
          // dealt with single value attributes (String, Number,
          // ByteArray)
          else {
            String value = "";
            value = convertToString(bValue);
            attrContainer.element(entry, value);
          }
        }
      }
      objElement.element("attributes", attrContainer);
    }
    if (crBean.getChildRepository() != null && crBean.getChildRepository().size() > 0) {
      // JSONObject childContainer = new JSONObject();
      JSONArray childContainer = new JSONArray();
      for (Iterator it = crBean.getChildRepository().iterator(); it.hasNext();) {

        CRResolvableBean chBean = (CRResolvableBean) it.next();

        JSONObject chElement = processElement(chBean);
        childContainer.add(chElement);
        // childContainer.element(chBean.getContentid(),chElement);
      }
      objElement.element("children", childContainer);
    }
    return objElement;
View Full Code Here

        }
      } else {
        objectString = config.getString("objects", "{objects:[]}");
      }
      JSONObject json = JSONObject.fromObject(objectString);
      JSONArray jsonObjects = json.getJSONArray("objects");
      for (Object object : jsonObjects) {
        if (object instanceof JSONObject) {
          objects.add(createCRResolvableBean((JSONObject) object));
        }
      }
View Full Code Here

        Locale locale = request.getLocale();
        if(!uiLabelObject.isEmpty()) {
            Set<String> resourceSet = UtilGenerics.checkSet(uiLabelObject.keySet());
            // Iterate over the resouce set
            for (String resource : resourceSet) {
                JSONArray labels = uiLabelObject.getJSONArray(resource);
                if (labels.isEmpty() || labels == null) {
                    continue;
                }

                // Iterate over the uiLabel List
                Iterator<String> jsonLabelIterator = UtilGenerics.cast(labels.iterator());
                JSONArray resourceLabelList = new JSONArray();
                while(jsonLabelIterator.hasNext()) {
                    String label = jsonLabelIterator.next();
                    String receivedLabel = UtilProperties.getMessage(resource, label, locale);
                    if (UtilValidate.isNotEmpty(receivedLabel)) {
                        resourceLabelList.add(receivedLabel);
                    }
                }
                jsonUiLabel.element(resource, resourceLabelList);
            }
        }
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.