-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Make optional user-data available in from_json #864
Copy link
Copy link
Closed
Labels
solution: proposed fixa fix for the issue has been proposed and waits for confirmationa fix for the issue has been proposed and waits for confirmationsolution: wontfixthe issue will not be fixed (either it is impossible or deemed out of scope)the issue will not be fixed (either it is impossible or deemed out of scope)
Description
I'd like to be able to supply optional user-data to json::parse which would then be retrievable in from_json. A naive implementation might look like this:
void from_json(const json& j, image& img, void* user_data)
{
const char* root_directory = reinterpret_cast<const char*>(user_data);
std::string filename = j["filename"];
img.data = load_external_dependency(std::string(root_directory) + "//" + filename);
}
// ...
json j = json::parse(json_string, "C:\\images\\");Or maybe this is already possible? Right now the only way I can see to do it requires global state or caching the data on the object and fixing it up after parsing.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
solution: proposed fixa fix for the issue has been proposed and waits for confirmationa fix for the issue has been proposed and waits for confirmationsolution: wontfixthe issue will not be fixed (either it is impossible or deemed out of scope)the issue will not be fixed (either it is impossible or deemed out of scope)