MCPcopy Create free account
hub / github.com/NVIDIA-RTX/Donut / LoadFromFile

Function LoadFromFile

src/core/json.cpp:47–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45namespace donut::json
46{
47 bool LoadFromFile(IFileSystem& fs, const std::filesystem::path& jsonFileName, Json::Value& documentRoot)
48 {
49 std::shared_ptr<IBlob> data = fs.readFile(jsonFileName);
50 if (!data)
51 {
52 log::error("Couldn't read file %s", jsonFileName.generic_string().c_str());
53 return false;
54 }
55
56 Json::CharReaderBuilder builder;
57 builder["collectComments"] = false;
58 Json::CharReader* reader = builder.newCharReader();
59
60 const char* dataPtr = static_cast<const char*>(data->data());
61 std::string errors;
62 bool success = reader->parse(dataPtr, dataPtr + data->size(), &documentRoot, &errors);
63
64 if (!success)
65 {
66 log::error("Couldn't parse JSON file %s:\n%s", jsonFileName.generic_string().c_str(), errors.c_str());
67 }
68
69 delete reader;
70
71 return success;
72 }
73
74 template<>
75 std::string Read<std::string>(const Json::Value& node, const std::string& defaultValue)

Callers 1

LoadWithThreadPoolMethod · 0.85

Calls 4

errorFunction · 0.85
readFileMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected