src/web: APIList and APIRandom use JsonArray.from
[nit.git] / 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