Package org.json

Examples of org.json.JSONArray


                return failureResultForStatusCode(responseStatus);

            JSONObject result = new JSONObject(get.getResponseBodyAsString());

            ResourceProxy resource = new ResourceProxy(path);
            JSONArray names = result.names();
            for (int i = 0; i < names.length(); i++) {
                String name = names.getString(i);
                Object object = result.get(name);
                if (object instanceof String) {
                    resource.addProperty(name, object);
                } else {
                    System.out.println("Property '" + name + "' of type '" + object.getClass().getName()
View Full Code Here


            input = method.getResponseBodyAsStream();

            JSONObject object = new JSONObject(new JSONTokener(new InputStreamReader(input)));

            JSONArray bundleData = object.getJSONArray("data");
            for (int i = 0; i < bundleData.length(); i++) {
                JSONObject bundle = bundleData.getJSONObject(i);
                String remotebundleSymbolicName = bundle.getString("symbolicName");
                Version bundleVersion = new Version(bundle.getString("version"));

                if (bundleSymbolicName.equals(remotebundleSymbolicName)) {
                    return bundleVersion;
View Full Code Here

   */
  private static DbusKeyFilter getDbusKeyFilter(JSONObject obj, ObjectMapper mapper)
    throws JSONException, IOException
  {
      String type = obj.getString(partitionTypeFieldName);
      JSONArray array = null;

      DbusKeyFilter configHolder = new DbusKeyFilter();
      configHolder.setPartitionType(PartitionType.valueOf(type));

      if (! obj.has(filterConfigFieldName) || obj.isNull(filterConfigFieldName))
      {
        return configHolder;
      }

      array = obj.getJSONArray(filterConfigFieldName);

      ArrayList<DbusFilter> filters = new ArrayList<DbusFilter>();

      for ( int i = 0; i < array.length(); i++)
      {
        filters.add(getDbusFilter(array.getString(i), configHolder.getPartitionType(), mapper));
      }

      configHolder.setFilters(filters);
      return configHolder;
  }
View Full Code Here

      switch (nextClean) {
      case '{':
        this.json = new ObjectNodeImpl(new JSONObject(jsonTokener));
        break;
      case '[':
        this.json = new ArrayNodeImpl(new JSONArray(jsonTokener));
        break;
      default:
        throw new IllegalStateException(String.format("Error processing token=%s from request=%s",nextClean, this.getRequest()));
      }
    } catch (Exception e) {
View Full Code Here

            String sid = getSid();
            String randNum = "0.0754233067456439";
            String contactsUrl = "http://mail.139.com/addr/apiserver/GetContactsDataByJs.ashx?sid=" + sid + "&rnd=" + randNum;
            String content = doGet(contactsUrl);
            JSONObject jsonObj = parseJSON(content, "GetUserAddrDataResp=");
            JSONArray jsonContacts = jsonObj.getJSONArray("Contacts");
            for (int i = 0; i < jsonContacts.length(); i++) {
                JSONObject jsonContact = (JSONObject) jsonContacts.get(i);
                String username = jsonContact.getString("c");
                String email = jsonContact.getString("y");
                contacts.add(new Contact(username, email));
            }
            return contacts;
View Full Code Here

      String json = doPost(contactsUrl, params);
      JSONTokener jsonTokener = new JSONTokener(json);
      Object o = jsonTokener.nextValue();
      JSONObject jsonObj = (JSONObject) o;
      JSONObject jsonData = jsonObj.getJSONObject("data");
      JSONArray jsonContacts = jsonData.getJSONArray("contact");
      List<Contact> contacts = new ArrayList<Contact>();
      for (int i = 0; i < jsonContacts.length(); i++) {
        jsonObj = jsonContacts.getJSONObject(i);
        if (jsonObj.has("name") && jsonObj.has("email")) {
          contacts.add(new Contact(jsonObj.getString("name")
              .replaceAll("&nbsp;", " "), jsonObj
              .getString("email")));
        }
View Full Code Here

          result.add(n);
      } catch(JsonArrayException e) {
        if (e.getArray()==null)
          throw e;

        JSONArray array = e.getArray();
        for(int i=0;i < array.length();i++){
          Object obj = array.get(i);
          result.add(factory(key, obj, array, i));
        }
      }
      return result;
    } catch (JSONException e) {
View Full Code Here

  public void addAtributesFor(HttpServletRequest request, URI resource,JSONObject representation) {
    IPath resourcePath = new Path(request.getServletPath() + (request.getPathInfo() == null ? "" : request.getPathInfo()));
   
    if ("/workspace".equals(request.getServletPath()) && resourcePath.segmentCount() == 2) {
      try {
        JSONArray projObjects = representation.getJSONArray("Children");
        for (int i = 0; i < projObjects.length(); i++) {
          JSONObject projectObject = (JSONObject) projObjects.get(i);
          if (checkMaqettaProject(projectObject)){
            projectObject.put(IDavinciServerConstants.MAQETTA_PROJECT, true);
          }else{
            projectObject.put("maqettaProject", false);
          }
        }
      } catch (JSONException e) {
        try {
          if(checkMaqettaProject(representation))
            representation.put(IDavinciServerConstants.MAQETTA_PROJECT, true);
          else
            representation.put("rootFolder", true);
        } catch (JSONException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
        } catch (CoreException e2) {
          // TODO Auto-generated catch block
          e2.printStackTrace();
        }
      } catch (CoreException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }else if("/file".equals(request.getServletPath()) ){
      try {
       
        /* if we get here, we're getting file contents from workspace. so need a way to check if its already a project
         *
         */
       
     
        JSONArray projObjects = representation.getJSONArray("Children");
        for (int i = 0; i < projObjects.length(); i++) {
          JSONObject projectObject = (JSONObject) projObjects.get(i);
          if(projectObject.getBoolean("Directory"))
            projectObject.put("maqettaProject", false);
       
        }
       
View Full Code Here

      e.printStackTrace();
    }
  }
 
  public IStorage[] listFiles(){
    JSONArray allProjects;
    Vector<VOrionProjectStorage> projects = new Vector<VOrionProjectStorage>();
    try {
      allProjects = webWorkspace.getProjectsJSON();
      for(int i=0;i<allProjects.length();i++){
        JSONObject projObj = (JSONObject)allProjects.opt(i);
        String id = projObj.getString("Id");
        WebProject result = WebProject.fromId(id);
        String name = result.getName();
        try {
          projects.add(new VOrionProjectStorage(name, result.getProjectStore(), result, this));
        } catch (CoreException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
    } catch (JSONException e) {
      //someone messed with the backing store and inserted something invalid- just wipe it out
      allProjects = new JSONArray();
    }
    return projects.toArray(new VOrionProjectStorage[projects.size()]);
  }
View Full Code Here

 
  public OrionUser(IPerson person) throws CoreException {
    super(person);
    this.webuser = WebUser.fromUserId(this.getUserID());
    try {
      JSONArray workspaceJson = webuser.getWorkspacesJSON();
      if (workspaceJson.length() != 0) {
        /* may need to default to other workspace here via the URL or a cookie, but taking first one found for now */
        JSONObject workObj = (JSONObject)workspaceJson.get(0);
        webWorkspace = WebWorkspace.fromId(workObj.getString("Id"));
      } else {
        // create default workspace for new user
        webWorkspace = createWorkspace(DEFAULT_WORKSPACE);
      }
View Full Code Here

TOP

Related Classes of org.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.