src/web: APIList and APIRandom use JsonArray.from
authorAlexandre Terrasa <alexandre@moz-code.org>
Thu, 2 Jun 2016 23:17:35 +0000 (19:17 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Thu, 2 Jun 2016 23:18:52 +0000 (19:18 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/web/model_api.nit

index 85a2360..df84816 100644 (file)
@@ -144,9 +144,7 @@ class APIList
        redef fun get(req, res) do
                var mentities = list_mentities(req)
                mentities = limit_mentities(req, mentities)
-               var arr = new JsonArray
-               for mentity in mentities do arr.add mentity
-               res.json arr
+               res.json new JsonArray.from(mentities)
        end
 end
 
@@ -167,9 +165,7 @@ class APIRandom
                var mentities = list_mentities(req)
                mentities = limit_mentities(req, mentities)
                mentities = randomize_mentities(req, mentities)
-               var arr = new JsonArray
-               for mentity in mentities do arr.add mentity
-               res.json arr
+               res.json new JsonArray.from(mentities)
        end
 end