Package org.json.jdk5.simple

Examples of org.json.jdk5.simple.JSONObject


    if(book != null){
      object.put("bookType", book.getBookType());
      object.put("label", book.getTitle());
      object.put("abstract", book.getAbstr());
     
      JSONArray authors = new JSONArray();
      if(book.getAuthors() != null)
        for(Person author : book.getAuthors())
          authors.add(author.getName());
     
      object.put("creator", authors);
     
      JSONArray keywords = new JSONArray();
      if(book.getKeywords() != null)
        keywords.addAll(book.getKeywords());
     
      object.put("keywords", keywords);
     
      this.addProperties(object, book.getOtherProperties());
View Full Code Here


    object.put("type", "Person");
    object.put("label", person.getName());
    object.put("homepage", person.getHomepage());
    object.put("bio", person.getBio());
   
    JSONArray emails = new JSONArray();
    if(person.getEmails() != null)
      emails.addAll(person.getEmails());
   
    object.put("email", emails);
   
    JSONArray knows = new JSONArray();
    if(person.getKnows() != null)
      knows.addAll(person.getKnows());
   
    object.put("knows", knows);
   
    JSONArray phones = new JSONArray();
    if(person.getPhones() != null)
      phones.addAll(person.getPhones());
   
    object.put("phones", phones);
   
    JSONArray interests = new JSONArray();
    if(person.getInterests() != null)
      interests.addAll(person.getInterests());
   
    object.put("interests", interests);
   
    this.addProperties(object, person.getOtherProperties());
View Full Code Here

      for(Map.Entry<String, Collection<String>> prop : map.entrySet()){
        String key = MbbEl.abbrURI(prop.getKey());
        int col = key.indexOf(':');
        if(col+1 < key.length()){
          String v = key.substring(col+1);
          JSONArray values = new JSONArray();
          values.addAll(prop.getValue());
         
          for(String val : prop.getValue()){
            if(v.contains("date") || v.contains("Date")){
              String d = getDateFromInt(val);
              if(d != null)
                sdate.add(d);
            }
          }
         
          object.put(v, values);
        }
      }
   
    if(sdate.size() > 0){
      JSONArray jdate = new JSONArray();
      jdate.addAll(sdate);
     
      object.put("fromDate", jdate);
      object.put("toDate", jdate);
    }
  }
View Full Code Here

        inbox.setIssueDate(new Date());
        inbox.setLabel("Inbox");
      }
    }
    JSONObject result = new JSONObject();
    JSONArray ja = new JSONArray();
   
    int i = 0;
   
    if(inbox!=null) {
      Iterator<XResource> it = inbox.listContent();
     
      while(it.hasNext())
      {
        XResource br = it.next();
        JSONObject jo = new JSONObject();
        jo.put("label", br.getLabel());
        jo.put("uri", br.getStringURI());
       
        ja.add(jo);
        i++;
     
    }
   
    result.put("result", ja);
View Full Code Here

  public static String getThesauri() {
    JSONArray ja = new JSONArray();
   
    for(ThesaurusContext context:Thesauri.getInstance().getContexts())
    {
      JSONObject jo = new JSONObject();
      jo.put("label", context.getLabel());
      jo.put("uri", context.getUri().toString());
     
      ja.add(jo);
    }
   
    return ja.toString();
View Full Code Here

  public void setImportedPost(SynchronizationPost _importedPost) {
    this.importedPost = _importedPost;
  }

  public JSONObject toJSONObject(){
    JSONObject json = new JSONObject();
    json.put("differenceType", synchronizationState.getMessage());
    if(storedPost != null){
      json.put("storedPostURI", storedPost.getHref());
      JSONArray tags = new JSONArray();
      for(String tag : storedPost.getTags()){
        tags.add(tag);
      }
      json.put("storedPostTags", tags);
      json.put("storedPostDesc", storedPost.getDescription());
    }else{
      json.put("storedPostURI",null);
    }
    if(importedPost != null){
      json.put("importedPostURI", importedPost.getHref());
      JSONArray tags = new JSONArray();
      for(String tag : importedPost.getTags()){
        tags.add(tag);
      }
      json.put("importedPostTags", tags);
      json.put("importedPostDesc", importedPost.getDescription());
    }else{
      json.put("importedPostURI", null);
    }
    return json;
  }
View Full Code Here

      if(lang.length()>2) lang = lang.substring(0, 2);
     
      feedId = FeedDbHandler.getInstance().addFeed(userId, dirId, feedType, lang, numOfChanges);
    }
     
    JSONObject jo = new JSONObject();
    jo.put("feedid", feedId);
    sendJSONResponse(resp, jo.toString());
  }
View Full Code Here

  public String getJSON()
  {
    Map<String,? extends Object> results = processFilter(true);
    JSONArray result = new JSONArray();
   
    JSONObject jomain = new JSONObject();
   
    if(results!=null)
    {
      result = (JSONArray)results.get("result");
     
      if(result!=null&&result.size()>0)
      {
        jomain.put("count",result.size());
        jomain.put("results", result);
        jomain.put("groups", results.get("groups"));
      }
      else
        jomain.put("count",0);
    }
    else
      jomain.put("count",0);
   
    jomain.put("person", this.person);
    return jomain.toString();
  }
View Full Code Here

            for(QueryRow qr : results) {
             
              String uri =  qr.getValue(results.getVariables().get(0)).toString();
              if(!avoidDuplicates.contains(uri))
              {
                JSONObject jo = new JSONObject();
                jo.put("uri", qr.getValue(results.getVariables().get(0)).toString().toString());
                jo.put("type", qr.getValue(results.getVariables().get(1)).toString().toString());
                jo.put("label", qr.getLiteralValue(results.getVariables().get(2)));
                try
                {
                  jo.put("content", qr.getLiteralValue(results.getVariables().get(3)));
                }
                catch (Exception e)
                {
                  jo.put("content", null);
                }
                try
                {
                  jo.put("creator", qr.getLiteralValue(results.getVariables().get(4)));
                }
                catch (Exception e)
                {
                  jo.put("creator", null);
                }
               
                resultJson.add(jo);
                avoidDuplicates.add(uri);
              }
View Full Code Here

        else if(results!=null)
        {
          int i=0;
          for(QueryRow qr:results) {
            i++;
            JSONObject jo = new JSONObject();

            jo.put("uri", qr.getValue(results.getVariables().get(0)).toString());
            jo.put("type",qr.getValue(results.getVariables().get(1)).toString());
            jo.put("label", qr.getLiteralValue(results.getVariables().get(2)));
            try {
              jo.put("content", qr.getLiteralValue(results.getVariables().get(3)));
            } catch(Exception e) {
              jo.put("content", null);
            }
            try {
              jo.put("creator", qr.getValue(results.getVariables().get(4)).toString());
            } catch (Exception e){
              jo.put("creator", null);
            }
            jo.put("group",entry.getURI().toString());
           
            resultJson.add(jo);
          }
          //and now the taxonomies
          if(i>0)
          {
            JSONObject concept = new JSONObject();
            concept.put("uri", entry.getURI().toString());
            concept.put("name", entry.getLabel());
            concept.put("type", entry.getContext().getLabel());//taxonomy
            List<TaxonomyEntry> path = entry.getPathFromRoot();
            path.remove(entry);
            StringBuilder sb = new StringBuilder();
            for(TaxonomyEntry te:path) {
              sb.append(te.getLabel());
              sb.append(" > ");
            }
            if(sb.length()>=3) {
              sb.insert(0, "Parents: ")//TODO: i18n or move to js.
              sb.delete(sb.length()-2, sb.length());
            }
            concept.put("mean", sb.toString());
            concept.put("count", i);
            groupsJson.add(concept);
          }
        }
      }
      //3. present results
View Full Code Here

TOP

Related Classes of org.json.jdk5.simple.JSONObject

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.