abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eli...@apache.org
Subject svn commit: r422930 - /incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/json/JSONWriter.java
Date Tue, 18 Jul 2006 00:44:10 GMT
Author: eliast
Date: Mon Jul 17 17:44:10 2006
New Revision: 422930

URL: http://svn.apache.org/viewvc?rev=422930&view=rev
Log:
- Fixed NPE bug in category

Modified:
    incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/json/JSONWriter.java

Modified: incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/json/JSONWriter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/json/JSONWriter.java?rev=422930&r1=422929&r2=422930&view=diff
==============================================================================
--- incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/json/JSONWriter.java
(original)
+++ incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/json/JSONWriter.java
Mon Jul 17 17:44:10 2006
@@ -69,6 +69,7 @@
       Object result = toJSON(base);
       out.write(result.toString());
     } catch(Exception e) {
+      e.printStackTrace();
       throw new IOException(e.getMessage());
     }    
   }
@@ -112,12 +113,21 @@
     
     JSONArray jscategories = new JSONArray();
     List<Category> categories = entry.getCategories();
-    for(Category category : categories) {
-      JSONObject jscategory = new JSONObject();
-      jscategory.put("scheme", category.getScheme().toString());
-      jscategory.put("term", category.getTerm());
-      jscategory.put("label", category.getLabel());
-      jscategories.put(jscategory);
+    for(Category category : categories) {      
+      if(category.getScheme() != null || 
+          category.getLabel() != null ||
+          category.getTerm() != null) {
+        JSONObject jscategory = new JSONObject();
+        if(category.getScheme() != null)
+          jscategory.put("scheme", category.getScheme().toString());
+        
+        if(category.getTerm() != null)
+          jscategory.put("term", category.getTerm());
+        
+        if(category.getLabel() != null)
+          jscategory.put("label", category.getLabel());
+        jscategories.put(jscategory);
+      }
     }
     jsentry.put("categories", jscategories);
     



Mime
View raw message