lib/popcorn: to_json accept serialization parameters
authorAlexandre Terrasa <alexandre@moz-code.org>
Thu, 17 Aug 2017 20:33:33 +0000 (16:33 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Fri, 8 Dec 2017 19:57:21 +0000 (14:57 -0500)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

lib/popcorn/pop_json.nit

index 8b14fc8..8a5ba58 100644 (file)
@@ -167,12 +167,12 @@ end
 redef class HttpResponse
 
        # Write data as JSON and set the right content type header.
-       fun json(json: nullable Serializable, status: nullable Int) do
+       fun json(json: nullable Serializable, status: nullable Int, plain, pretty: nullable Bool) do
                header["Content-Type"] = media_types["json"].as(not null)
                if json == null then
                        send(null, status)
                else
-                       send(json.to_json, status)
+                       send(json.serialize_to_json(plain or else true, pretty or else false), status)
                end
        end