MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / Parse

Method Parse

CodeFormatServer/src/Session/Protocol/ProtocolParser.cpp:10–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8}
9
10void ProtocolParser::Parse(std::string_view msg) {
11 auto jsonMessage = nlohmann::json::parse(msg);
12 if (jsonMessage["id"].is_number()) {
13 _id = jsonMessage["id"].get<int>();
14 } else if (jsonMessage["id"].is_string()) {
15 _id = jsonMessage["id"].get<std::string>();
16 }
17
18 if (jsonMessage["method"].is_string()) {
19 _method = jsonMessage["method"].get<std::string>();
20 }
21 if (jsonMessage["params"].is_object()) {
22 _params = jsonMessage["params"];
23 }
24}
25
26nlohmann::json ProtocolParser::GetParams() {
27 return _params;

Callers 2

RunMethod · 0.45
RunMethod · 0.45

Calls 1

parseFunction · 0.50

Tested by

no test coverage detected