From 4c2560b5a6b1d45c7d5d1b6c439a1f73d1601a1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Mon, 29 May 2017 10:43:14 +0300 Subject: [PATCH] MXS-1220: Pretty-print by default The REST API now pretty-prints by default. This is done to make it easier to use the API with browsers that don't have an integrated REST API client. --- server/core/admin.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/core/admin.cc b/server/core/admin.cc index 4f925d5e5..8f83c071b 100644 --- a/server/core/admin.cc +++ b/server/core/admin.cc @@ -121,7 +121,14 @@ int Client::process(string url, string method, const char* upload_data, size_t * if (js) { - int flags = request.get_option("pretty") == "true" ? JSON_INDENT(4) : 0; + int flags = 0; + string pretty = request.get_option("pretty"); + + if (pretty == "true" || pretty.length() == 0) + { + flags |= JSON_INDENT(4); + } + data = mxs::json_dump(js, flags); }