Error C2039 : 'json_sax_dom_callback_parser': is not a member of 'nlohmann::json_abi_v3_11_3::detail'
Closed this issue ยท 1 comments
Description
Hello Everyone
This is my first issue report, so please be kind and understanding. ๐
I am working on creating a simple To-Do App in C++. For storing my "tasks," I am using the nlohmann/json library. However, I encounter an error (mentioned in the headline) whenever I try to create a nlohmann::json variable within a class. See Code example below, this should tell you more about the issue.
Das Problem tritt auf, wenn man in der Klasse im Feld private: oder public: eine nlohmann::json instanz erstellt.
Reproduction steps
Code with Error
export class MainFrame : public wxFrame {
private:
nlohmann::json jsonArr;
}
MainFrame::MainFrame() : wxFrame(nullptr, wxID_ANY, "Todo List") {
if (JSONFilesExists())
{
LoadJSONFile();
}
else
{
CreateJSONFile();
}
jsonArr = nlohmann::json::array();
nlohmann::json jsonObject = {
{"id", tasks.size()},
{"name", "fu"},
{"description", " djsakdasld" },
{"created", 232132132},
};
nlohmann::json x2 = {
{"id", tasks.size()},
{"name", "d"},
{"description", " djsakdasld" },
{"created", 232132132},
};
jsonArr.push_back(jsonObject);
jsonArr.push_back(x2);
std::filesystem::path outputFile = GetDataPath() / "tasks.json";
std::ofstream output(outputFile, std::ios::app);
if (output.is_open())
{
output << std::setw(4) << jsonArr << std::endl;
output.close();
}
}
Code that works
export class MainFrame : public wxFrame {
}
MainFrame::MainFrame() : wxFrame(nullptr, wxID_ANY, "Todo List")
{
nlohmann::json jsonArr = nlohmann::json::array();
nlohmann::json jsonObject = {
{"id", tasks.size()},
{"name", "fu"},
{"description", " djsakdasld" },
{"created", 232132132},
};
nlohmann::json x2 = {
{"id", tasks.size()},
{"name", "d"},
{"description", " djsakdasld" },
{"created", 232132132},
};
jsonArr.push_back(jsonObject);
jsonArr.push_back(x2);
std::filesystem::path outputFile = GetDataPath() / "tasks.json";
std::ofstream output(outputFile, std::ios::app);
if (output.is_open())
{
output << std::setw(4) << jsonArr << std::endl;
output.close();
}
}
Expected vs. actual results
Expected
written into a json file
[
{
"created": 232132132,
"description": " djsakdasld",
"id": 0,
"name": "fu"
},
{
"created": 232132132,
"description": " djsakdasld",
"id": 0,
"name": "d"
}
]
actual results
Build with surface heuristics started at 08:41:19
Use build tool: C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\MSBuild.exe
CONSOLE: MSBuild version 17.11.9+a69bbaaf5 for .NET Framework
CONSOLE: Build started 12/6/2024 8:41:19 AM.
CONSOLE: Project "C:\Users\Markus\AppData\Local\Temp\Zapugic.proj" on node 1 (default targets).
CONSOLE: ControllerTarget:
CONSOLE: Run controller from C:\Program Files\JetBrains\Rider\r2r\2024.3.0R\A2EF948D5832C6BB33EEC5846BAF524\JetBrains.Platform.MsBuildTask.v17.dll
0>------- Started building project: Todo_List
Scanning sources for module dependencies...
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\bin\HostX64\x64\CL.exe /c /IC:\Users\Markus\Desktop\Todo_list\header /I"C:\Program Files\Todo_List\include" /Zi /nologo /W4 /WX /diagnostics:column /FS /Od /Ob0 /D _UNICODE /D UNICODE /D WIN32 /D _WINDOWS /D NOMINMAX /D _WIN32_WINNT=_WIN32_WINNT_WIN7 /D WIN32_LEAN_AND_MEAN /D VC_EXTRALEAN /D UNICODE /D _UNICODE /D WXMSW /D WXUSINGDLL /D "CMAKE_INTDIR="Debug"" /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /std:c++latest /ifcOutput "C:\Users\Markus\Desktop\Todo_list\build\Todo_List.dir\Debug\MainFrame.ixx.ifc" /scanDependencies "Todo_List.dir\Debug\" /Fo"Todo_List.dir\Debug\MainFrame.ixx.obj" /Fd"Todo_List.dir\Debug\vc143.pdb" /external:W0 /Gd /interface /errorReport:prompt /external:I "C:/Users/Markus/Desktop/Todo_list/build/vcpkg_installed/x64-windows/lib/mswud" /external:I "C:/Users/Markus/Desktop/Todo_list/build/vcpkg_installed/x64-windows/include" /TP C:\Users\Markus\Desktop\Todo_list\src\MainFrame.ixx
MainFrame.ixx
Compiling...
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\bin\HostX64\x64\CL.exe /c /IC:\Users\Markus\Desktop\Todo_list\header /I"C:\Program Files\Todo_List\include" /reference std=C:\Users\Markus\Desktop\Todo_list\build\Todo_List.dir\Debug\microsoft\STL\std.ixx.ifc /reference TodoList=C:\Users\Markus\Desktop\Todo_list\build\Todo_List.dir\Debug\TodoList.ixx.ifc /reference Task=C:\Users\Markus\Desktop\Todo_list\build\Todo_List.dir\Debug\Task.ixx.ifc /reference CreateTaskWindow=C:\Users\Markus\Desktop\Todo_list\build\Todo_List.dir\Debug\CreateTaskWindow.ixx.ifc /Zi /nologo /W4 /WX /diagnostics:column /FS /Od /Ob0 /D _UNICODE /D UNICODE /D WIN32 /D _WINDOWS /D NOMINMAX /D _WIN32_WINNT=_WIN32_WINNT_WIN7 /D WIN32_LEAN_AND_MEAN /D VC_EXTRALEAN /D UNICODE /D _UNICODE /D WXMSW /D WXUSINGDLL /D "CMAKE_INTDIR="Debug"" /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /std:c++latest /ifcOutput "C:\Users\Markus\Desktop\Todo_list\build\Todo_List.dir\Debug\MainFrame.ixx.ifc" /Fo"Todo_List.dir\Debug\MainFrame.ixx.obj" /Fd"Todo_List.dir\Debug\vc143.pdb" /sourceDependencies "C:\Users\Markus\Desktop\Todo_list\build\Todo_List.dir\Debug\MainFrame.ixx.ifc.d.json" /external:W0 /Gd /interface /errorReport:prompt /external:I "C:/Users/Markus/Desktop/Todo_list/build/vcpkg_installed/x64-windows/lib/mswud" /external:I "C:/Users/Markus/Desktop/Todo_list/build/vcpkg_installed/x64-windows/include" /TP C:\Users\Markus\Desktop\Todo_list\src\MainFrame.ixx
MainFrame.ixx
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\bin\HostX64\x64\CL.exe /c /IC:\Users\Markus\Desktop\Todo_list\header /I"C:\Program Files\Todo_List\include" /reference MainFrame=C:\Users\Markus\Desktop\Todo_list\build\Todo_List.dir\Debug\MainFrame.ixx.ifc /reference std=C:\Users\Markus\Desktop\Todo_list\build\Todo_List.dir\Debug\microsoft\STL\std.ixx.ifc /reference TodoList=C:\Users\Markus\Desktop\Todo_list\build\Todo_List.dir\Debug\TodoList.ixx.ifc /reference Task=C:\Users\Markus\Desktop\Todo_list\build\Todo_List.dir\Debug\Task.ixx.ifc /reference CreateTaskWindow=C:\Users\Markus\Desktop\Todo_list\build\Todo_List.dir\Debug\CreateTaskWindow.ixx.ifc /Zi /nologo /W4 /WX /diagnostics:column /FS /Od /Ob0 /D _UNICODE /D UNICODE /D WIN32 /D _WINDOWS /D NOMINMAX /D _WIN32_WINNT=_WIN32_WINNT_WIN7 /D WIN32_LEAN_AND_MEAN /D VC_EXTRALEAN /D UNICODE /D _UNICODE /D WXMSW /D WXUSINGDLL /D "CMAKE_INTDIR="Debug"" /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /std:c++latest /ifcOutput "C:\Users\Markus\Desktop\Todo_list\build\Todo_List.dir\Debug\TodoListGUI.ixx.ifc" /Fo"Todo_List.dir\Debug\TodoListGUI.ixx.obj" /Fd"Todo_List.dir\Debug\vc143.pdb" /sourceDependencies "C:\Users\Markus\Desktop\Todo_list\build\Todo_List.dir\Debug\TodoListGUI.ixx.ifc.d.json" /external:W0 /Gd /interface /errorReport:prompt /external:I "C:/Users/Markus/Desktop/Todo_list/build/vcpkg_installed/x64-windows/lib/mswud" /external:I "C:/Users/Markus/Desktop/Todo_list/build/vcpkg_installed/x64-windows/include" /TP C:\Users\Markus\Desktop\Todo_list\src\TodoListGUI.ixx
TodoListGUI.ixx
0>json.hpp(120,38): Error C2039 : 'json_sax_dom_callback_parser': is not a member of 'nlohmann::json_abi_v3_11_3::detail'
(compiling source file '../src/TodoListGUI.ixx')
C:\Users\Markus\Desktop\Todo_list\build\vcpkg_installed\x64-windows\include\nlohmann\detail\output\serializer.hpp(35,11):
see declaration of 'nlohmann::json_abi_v3_11_3::detail'
C:\Users\Markus\Desktop\Todo_list\build\vcpkg_installed\x64-windows\include\nlohmann\json.hpp(120,38):
the template instantiation context (the oldest one first) is
C:\Users\Markus\Desktop\Todo_list\src\MainFrame.ixx(30,20):
see reference to class template instantiation 'nlohmann::json_abi_v3_11_3::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits,std::allocator>,bool,int64_t,uint64_t,double,std::allocator,nlohmann::json_abi_v3_11_3::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>,void>' being compiled
0>------- Finished building project: Todo_List. Succeeded: False. Errors: 1. Warnings: 0
Minimal code example
No response
Error messages
0>json.hpp(120,38): Error C2039 : 'json_sax_dom_callback_parser': is not a member of 'nlohmann::json_abi_v3_11_3::detail'
(compiling source file '../src/TodoListGUI.ixx')
C:\Users\Markus\Desktop\Todo_list\build\vcpkg_installed\x64-windows\include\nlohmann\detail\output\serializer.hpp(35,11):
see declaration of 'nlohmann::json_abi_v3_11_3::detail'
C:\Users\Markus\Desktop\Todo_list\build\vcpkg_installed\x64-windows\include\nlohmann\json.hpp(120,38):
the template instantiation context (the oldest one first) is
C:\Users\Markus\Desktop\Todo_list\src\MainFrame.ixx(30,20):
see reference to class template instantiation 'nlohmann::json_abi_v3_11_3::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char>>,bool,int64_t,uint64_t,double,std::allocator,nlohmann::json_abi_v3_11_3::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>,void>' being compiled
0>------- Finished building project: Todo_List. Succeeded: False. Errors: 1. Warnings: 0
Compiler and operating system
MinGW-w64, Windows 11
Library version
newest
Validation
- The bug also occurs if the latest version from the
develop
branch is used. - I can successfully compile and run the unit tests.