修改运行监控场站及设备信息查询接口

This commit is contained in:
lixiaoyuan
2025-09-06 15:23:07 +08:00
parent aca9a8f0ae
commit 566a3b050c
17 changed files with 468 additions and 302 deletions

View File

@@ -5,7 +5,7 @@
#include <memory>
#include <iostream>
using NJsonNode = nlohmann::json;
using njson = nlohmann::json;
/// =============================================================================================
/// 使用说明:
@@ -48,10 +48,10 @@ using NJsonNode = nlohmann::json;
// std::vector<int> v1;
// v1 = j.at["data"].get<std::vector<int>>()
class NJson
class JSON
{
public:
static bool load(std::string jsonfile, NJsonNode& json)
static bool load(std::string jsonfile, njson& json)
{
std::ifstream ifs(jsonfile);
if (!ifs.is_open()) { return false; }
@@ -60,11 +60,11 @@ public:
return true;
}
static bool parse(std::string jsonstr, NJsonNode& json)
static bool parse(std::string jsonstr, njson& json)
{
try
{
if (!jsonstr.empty()) { json = NJsonNode::parse(jsonstr); }
if (!jsonstr.empty()) { json = njson::parse(jsonstr); }
}
catch (nlohmann::json::parse_error& e)
{
@@ -75,7 +75,7 @@ public:
}
template <typename T>
static void read(NJsonNode& json, std::string k, T& v)
static void read(njson& json, std::string k, T& v)
{
try
{
@@ -89,8 +89,8 @@ public:
static void parse(std::string jsonstr, std::vector<std::string>& vd)
{
NJsonNode jsonroot;
if (NJson::parse(jsonstr, jsonroot))
njson jsonroot;
if (JSON::parse(jsonstr, jsonroot))
{
vd = jsonroot.get<std::vector<std::string>>();
}