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

@@ -4,6 +4,16 @@ project(WhetstoneEditor LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# nlohmann/json (header-only, fetched once)
include(FetchContent)
FetchContent_Declare(
json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.11.3
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(json)
add_executable(step1_test tests/step1_test.cpp)
target_include_directories(step1_test PRIVATE src)
@@ -15,3 +25,7 @@ target_include_directories(step3_test PRIVATE src)
add_executable(step4_test tests/step4_test.cpp)
target_include_directories(step4_test PRIVATE src)
add_executable(step5_test tests/step5_test.cpp)
target_include_directories(step5_test PRIVATE src)
target_link_libraries(step5_test PRIVATE nlohmann_json::nlohmann_json)