contrib: update clients of `to_json_string`
authorAlexis Laferrière <alexis.laf@xymus.net>
Fri, 13 May 2016 18:04:56 +0000 (14:04 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Fri, 13 May 2016 18:19:29 +0000 (14:19 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

contrib/benitlux/src/benitlux_controller.nit
contrib/tinks/src/client/linux_client.nit
contrib/tnitter/src/action.nit
contrib/tnitter/src/push.nit

index 5f5513a..dbb0974 100644 (file)
@@ -348,7 +348,7 @@ redef class HttpResponse
        init ok(data: Serializable)
        do
                init 200
-               body = data.to_json_string
+               body = data.serialize_to_json
        end
 
        # Respond with a `BenitluxError` in JSON and a code 403
@@ -356,7 +356,7 @@ redef class HttpResponse
        do
                init 403
                var error = new BenitluxTokenError("Forbidden", "Invalid or outdated token.")
-               body = error.to_json_string
+               body = error.serialize_to_json
        end
 
        # Respond with a `BenitluxError` in JSON and a code 400
@@ -364,7 +364,7 @@ redef class HttpResponse
        do
                init 400
                var error = new BenitluxError("Bad Request", "Application error, or it needs to be updated.")
-               body = error.to_json_string
+               body = error.serialize_to_json
        end
 
        # Respond with a `BenitluxError` in JSON and a code 500
@@ -372,6 +372,6 @@ redef class HttpResponse
        do
                init 500
                var error = new BenitluxError("Internal Server Error", "Server error, try again later.")
-               body = error.to_json_string
+               body = error.serialize_to_json
        end
 end
index 6ef6b15..bd60702 100644 (file)
@@ -54,8 +54,7 @@ redef class App
 
                # Save the default config to pretty Json
                var cc = new ClientConfig
-               var json = cc.to_plain_json
-               json = json.replace(",", ",\n")
+               var json = cc.serialize_to_json(plain=true, pretty=true)
                json.write_to_file config_path
 
                return cc
index ad41a71..60ee384 100644 (file)
@@ -266,14 +266,14 @@ class TnitterREST
                        db.close
 
                        var response = new HttpResponse(200)
-                       response.body = posts.to_json_string
+                       response.body = posts.serialize_to_json
                        return response
                end
 
                # Format not recognized
                var error = new Error("Bad Request")
                var response = new HttpResponse(400)
-               response.body = error.to_json_string
+               response.body = error.serialize_to_json
                return response
        end
 end
index cdb2945..bc47789 100644 (file)
@@ -46,7 +46,7 @@ redef class DB
                # Everyone gets the same response
                var posts = list_posts(0, 16)
                var response = new HttpResponse(400)
-               response.body = posts.to_json_string
+               response.body = posts.serialize_to_json
 
                for conn in push_connections do
                        # Complete the answer to `conn`