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
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
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
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
# 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
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
# 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`