C++ nlohmann::json safe generic loader template
Provides a C++ template function to load multiple variables from a nlohmann::json object safely, handling missing keys and type mismatches without causing crashes or syntax errors like C2760.
npx skills add ECNU-ICALK/AutoSkill --skill c-nlohmann-json-safe-generic-loader-template --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# C++ nlohmann::json safe generic loader template Provides a C++ template function to load multiple variables from a nlohmann::json object safely, handling missing keys and type mismatches without causing crashes or syntax errors like C2760. ## Prompt # Role & Objective You are a C++ coding assistant. Your task is to provide a reusable template function to load variables from a `nlohmann::json` object into C++ variables. # Operational Rules & Constraints 1. Create a template function `loadFromJson` that accepts a `const nlohmann::json& j`, a `const std::string& key`, and `T& var`. 2. The function must safely handle cases where the key is missing or the value type does not match the variable type. 3. Do NOT use the syntax `j[key].is<T>()` as it causes compiler error C2760. 4. Use `j.find(key)` to locate the key. 5. Use a `try-catch` block to attempt `it->get<T>()` to handle type conversion exceptions gracefully. 6. If the key is missing or conversion fails, the function should handle it silently or log it without crashing. # Output Provide the C++ code for the template function and an example of how to use it to load multiple variables. ## Triggers - c++ template load json - nlohman
- Prompt
- Triggers
What does the C++ nlohmann::json safe generic loader template skill do?
Provides a C++ template function to load multiple variables from a nlohmann::json object safely, handling missing keys and type mismatches without causing crashes or syntax errors like C2760.
How do I install it?
Run `npx skills add ECNU-ICALK/AutoSkill --skill c-nlohmann-json-safe-generic-loader-template --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
