25#ifndef QB_IO_PROTOCOL_JSON_H
26#define QB_IO_PROTOCOL_JSON_H
28#include "nlohmann/json.hpp"
50template <
typename IO_>
63 explicit json(IO_ &io) noexcept
89 const auto parsed = this->
shiftSize(size);
90 const auto data = this->
_io.in().cbegin();
94 nlohmann::json::parse(std::string_view(data, parsed),
nullptr,
false)});
113template <
typename IO_>
153 const auto parsed = this->
shiftSize(size);
154 const auto data = this->
_io.in().cbegin();
156 parsed, data, nlohmann::json::from_msgpack(std::string_view(data, parsed))});
IO_ & _io
Definition protocol.h:166
Protocol for messages delimited by a specific single byte character.
Definition base.h:48
std::size_t shiftSize(std::size_t const size) const noexcept
Definition base.h:81
json_packed()=delete
Default constructor (deleted)
void onMessage(std::size_t size) noexcept final
Process a received message.
Definition json.h:152
json_packed(IO_ &io) noexcept
Constructor with I/O reference.
Definition json.h:126
void onMessage(std::size_t size) noexcept final
Process a received message.
Definition json.h:88
json()=delete
Default constructor (deleted)
json(IO_ &io) noexcept
Constructor with I/O reference.
Definition json.h:63
Base protocol implementations for message framing in the QB IO system.
Structure representing a JSON message.
Definition json.h:73
const std::size_t size
Message size.
Definition json.h:74
nlohmann::json json
Parsed JSON object.
Definition json.h:76
const char * data
Pointer to the raw data.
Definition json.h:75
Structure representing a MessagePack encoded JSON message.
Definition json.h:136
const std::size_t size
Message size.
Definition json.h:137
const char * data
Pointer to the raw data.
Definition json.h:138
nlohmann::json json
Parsed JSON object.
Definition json.h:139