From: Alexandre Terrasa Date: Thu, 17 Aug 2017 20:33:33 +0000 (-0400) Subject: lib/popcorn: to_json accept serialization parameters X-Git-Url: http://nitlanguage.org lib/popcorn: to_json accept serialization parameters Signed-off-by: Alexandre Terrasa --- diff --git a/lib/popcorn/pop_json.nit b/lib/popcorn/pop_json.nit index 8b14fc8..8a5ba58 100644 --- a/lib/popcorn/pop_json.nit +++ b/lib/popcorn/pop_json.nit @@ -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