Logo Pico-Framework A web-first embedded framework for C++
Loading...
Searching...
No Matches
JsonView.h
Go to the documentation of this file.
1
13 #pragma once
15 #include <nlohmann/json.hpp>
16
20 class JsonView : public FrameworkView {
21 public:
22 explicit JsonView(const nlohmann::json& payload);
23
24 std::string render(const std::map<std::string, std::string>& context = {}) const override;
25 std::string getContentType() const override;
26
27 private:
28 nlohmann::json payload_;
29 };
30
Abstract base class for all views in the PicoFramework.
A view that renders structured JSON and returns "application/json" content type.
Definition JsonView.h:20
nlohmann::json payload_
Definition JsonView.h:28
std::string getContentType() const override
Return the MIME content type for this view.
Definition JsonView.cpp:22
std::string render(const std::map< std::string, std::string > &context={}) const override
Render the view body.
Definition JsonView.cpp:17