summaryrefslogtreecommitdiff
path: root/src/lib/http_server.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-10-15 00:15:31 +0200
committerCarl Hetherington <cth@carlh.net>2026-02-16 01:20:17 +0100
commit290672d7b4b3c454f02a42d95df3ddfae307542f (patch)
treecf5531f768b86e40a7ba41743b6ec30e00249e7c /src/lib/http_server.cc
parente23af8c3cf898dd443de7e081542f039f6763cec (diff)
Use nlohmann for JSON.
Diffstat (limited to 'src/lib/http_server.cc')
-rw-r--r--src/lib/http_server.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/lib/http_server.cc b/src/lib/http_server.cc
index 3dab26d1e..294d350ac 100644
--- a/src/lib/http_server.cc
+++ b/src/lib/http_server.cc
@@ -25,6 +25,7 @@
#include "http_server.h"
#include "util.h"
#include "variant.h"
+#include <nlohmann/json.hpp>
#include <boost/algorithm/string.hpp>
#include <stdexcept>
@@ -96,15 +97,14 @@ HTTPServer::get(string const& url)
if (url == "/") {
return Response(200, fmt::format(dcp::file_to_string(resources_path() / "web" / "index.html"), variant::dcpomatic_player()));
} else if (url == "/api/v1/status") {
- auto json = string{"{ "};
+ nlohmann::json json;
{
boost::mutex::scoped_lock lm(_mutex);
- json += fmt::format("\"playing\": {}, ", _playing ? "true" : "false");
- json += fmt::format("\"position\": \"{}\", ", seconds_to_hms(_position.seconds()));
- json += fmt::format("\"dcp_name\": \"{}\"", _dcp_name);
+ json["playing"] = _playing;
+ json["position"] = seconds_to_hms(_position.seconds());
+ json["dcp_name"] = _dcp_name;
}
- json += " }";
- auto response = Response(200, json);
+ auto response = Response(200, json.dump());
response.set_type(Response::Type::JSON);
return response;
} else {