dl
dl_json.h
浏览该文件的文档.
1
12#pragma once
13
14#include <json.hpp>
15
16using json = nlohmann::json;
17
18namespace dl::Json
19{
20
25json Parse(std::string_view path_name);
26
27
31template<typename T>
32bool Get(const json& j, const std::string& name, T& t)
33{
34 auto iter = j.find(name);
35 if (iter == j.end())
36 return false;
37 try
38 {
39 t = *iter;
40 return true;
41 }
42 catch (nlohmann::detail::exception&)
43 {
44 }
45 return false;
46}
47
48
49}
50
nlohmann::json json
Definition: dl_json.h:16
json Parse(std::string_view path_name)
从 文件 构建json对象
bool Get(const json &j, const std::string &name, T &t)
从json返回值,不存在则返回false,并且不进行任何操作
Definition: dl_json.h:32