mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sro...@apache.org
Subject svn commit: r1397500 - /mahout/trunk/integration/src/main/java/org/apache/mahout/cf/taste/web/RecommenderServlet.java
Date Fri, 12 Oct 2012 09:38:52 GMT
Author: srowen
Date: Fri Oct 12 09:38:51 2012
New Revision: 1397500

URL: http://svn.apache.org/viewvc?rev=1397500&view=rev
Log:
MAHOUT-1101 remove trailing comma from JSON array in output

Modified:
    mahout/trunk/integration/src/main/java/org/apache/mahout/cf/taste/web/RecommenderServlet.java

Modified: mahout/trunk/integration/src/main/java/org/apache/mahout/cf/taste/web/RecommenderServlet.java
URL: http://svn.apache.org/viewvc/mahout/trunk/integration/src/main/java/org/apache/mahout/cf/taste/web/RecommenderServlet.java?rev=1397500&r1=1397499&r2=1397500&view=diff
==============================================================================
--- mahout/trunk/integration/src/main/java/org/apache/mahout/cf/taste/web/RecommenderServlet.java
(original)
+++ mahout/trunk/integration/src/main/java/org/apache/mahout/cf/taste/web/RecommenderServlet.java
Fri Oct 12 09:38:51 2012
@@ -132,12 +132,18 @@ public final class RecommenderServlet ex
     response.setHeader("Cache-Control", "no-cache");
     PrintWriter writer = response.getWriter();
     writer.print("{\"recommendedItems\":{\"item\":[");
+    boolean first = true;
     for (RecommendedItem recommendedItem : items) {
+      if (first) {
+        first = false;
+      } else {
+        writer.print(',');
+      }
       writer.print("{\"value\":\"");
       writer.print(recommendedItem.getValue());
       writer.print("\",\"id\":\"");
       writer.print(recommendedItem.getItemID());
-      writer.print("\"},");
+      writer.print("\"}");
     }
     writer.println("]}}");
   }



Mime
View raw message