Sprint 2 Step 5: JSON serialization with nlohmann/json

toJson(ASTNode*) recursively serializes the AST to JSON with id, concept,
properties, and children structure. Added childRoles() to ASTNode for
enumeration. FetchContent pulls nlohmann/json v3.11.3. Test serializes the
full Calculator model and verifies every node in the JSON output.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Bill
2026-02-06 19:11:48 -07:00
parent 71cd903fa8
commit 5579a4747f
4 changed files with 300 additions and 0 deletions

View File

@@ -45,6 +45,15 @@ public:
return it != children_.end() ? it->second : empty;
}
// Get all child role names
std::vector<std::string> childRoles() const {
std::vector<std::string> roles;
for (const auto& [role, _] : children_) {
roles.push_back(role);
}
return roles;
}
// Get all children across all roles
std::vector<ASTNode*> allChildren() const {
std::vector<ASTNode*> result;