Package net.sf.json

Examples of net.sf.json.JSONArray


        if (UtilValidate.isNotEmpty(requiredLabels)) {
            // 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, response);
        return "success";
View Full Code Here


        int len = 0;
        while ((len = in.read(buffer)) > 0) {
            sb.append(buffer, 0, len);
        }
        if (target != null && sb.length() > 0 && sb.charAt(0) == '[') {
            JSONArray jsonArray = JSONArray.fromObject(sb.toString());
            if (target.getClass().isArray()) {
                JSONArray.toArray(jsonArray, target, new JsonConfig());
            } else {
                JSONArray.toList(jsonArray, target, new JsonConfig());
            }
View Full Code Here

    }

    public String fromObject(Object obj, String resultCode, Writer stream) throws IOException {
        if (obj != null) {
            if (isArray(obj)) {
                JSONArray jsonArray = JSONArray.fromObject(obj);
                stream.write(jsonArray.toString());
            } else {
                JSONObject jsonObject = JSONObject.fromObject(obj);
                stream.write(jsonObject.toString());
            }
        }
View Full Code Here

        }

        List<ParameterValue> values = new ArrayList<ParameterValue>();
       
        JSONObject formData = req.getSubmittedForm();
        JSONArray a = JSONArray.fromObject(formData.get("parameter"));

        for (Object o : a) {
            JSONObject jo = (JSONObject) o;
            String name = jo.getString("name");
View Full Code Here

       
        String content = result.getWebResponse().getContentAsString();
        System.out.println(content);
        JSONObject jsonContent = (JSONObject)JSONSerializer.toJSON(content);
        Assert.assertNotNull(jsonContent);
        JSONArray jsonArray = jsonContent.getJSONArray("suggestions");
        Assert.assertNotNull(jsonArray);
       
        Assert.assertEquals(2, jsonArray.size());
       
        boolean foundProjectName = false;
        boolean foundDispayName = false;
        for(Object suggestion : jsonArray) {
            JSONObject jsonSuggestion = (JSONObject)suggestion;
View Full Code Here

    }

    public List<GithubLogEntry> getLogEntries() {
        List<GithubLogEntry> logEntries = new ArrayList<GithubLogEntry>();
        if (!isPullRequest()) {
            JSONArray commits = payloadJson.getJSONArray("commits");
            for (Object commit : commits) {
                logEntries.add(convertToLogEntry((Map<String, Object>) commit));
            }
        }
        return logEntries;
View Full Code Here

                        }

                        return json;
                    } else if (obj instanceof Collection) {
                        Collection col = (Collection) obj;
                        JSONArray json = new JSONArray();
                        Iterator it = col.iterator();

                        while (it.hasNext()) {
                            json.add(toJSONObject(it.next()));
                        }

                        return json;
                    } else if (obj instanceof Number) {
                        return obj;
View Full Code Here

            }

            return json;
        } else if (obj instanceof Collection) {
            Collection col = (Collection) obj;
            JSONArray json = new JSONArray();
            Iterator it = col.iterator();

            while (it.hasNext()) {
                json.add(toJSONObject(it.next()));
            }

            return json;
        } else if (obj instanceof Number) {
            return obj;
View Full Code Here

  public static TASRun parse(String json) throws JSONException
  {
    TASRun tRun = new TASRun();
    float totalTime = 0;
    float suiteTime = 0;
    JSONArray jSuites = JSONArray.fromObject(json);
    JSONArray jClasses;
    JSONObject jSuite;
    TASSuite tSuite;

    String className;
    String packageName;
View Full Code Here

   
  private static void addTestClasses(JSONArray classes, TASSuite suite) throws JSONException
  {
    JSONObject jTestClass;
    TASClass tClass;
    JSONArray jMethods;
   
    String className;
    String packageName;
    String fullClass;
    for (int i=0; i<classes.length(); i++)
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.