mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-28 11:19:24 +08:00
修改运行监控场站及设备信息查询接口
This commit is contained in:
@@ -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>>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user