29 lines
489 B
C++
29 lines
489 B
C++
#include "io/dl_json.h"
|
||
|
||
#include "io/dl_file.h"
|
||
#include "io/dl_log.h"
|
||
|
||
namespace dl
|
||
{
|
||
|
||
json Json::Parse(std::string_view path_name)
|
||
{
|
||
std::ifstream ifs = File::Get(path_name);
|
||
if (!ifs.is_open())
|
||
{
|
||
log_err("json文件读取失败:{}!", path_name);
|
||
}
|
||
try
|
||
{
|
||
//j = json::parse(buf.data(), buf.data() + buf.size());
|
||
json j = json::parse(ifs);
|
||
return j;
|
||
}
|
||
catch (nlohmann::detail::exception& e)
|
||
{
|
||
log_err("{}解析失败:{}", path_name, e.what());
|
||
}
|
||
return {};
|
||
}
|
||
|
||
} |