Using fifo_map with base class and derived class #2023
Labels
kind: question
solution: duplicate
the issue is a duplicate; refer to the linked issue instead
solution: proposed fix
a fix for the issue has been proposed and waits for confirmation
Hey @nlohmann and @Daniel599 !
I am currently trying to generate JSON with ordered keys and therefore used the workaround method from @Daniel599 . I just copy-pasted your workaround code and it worked as aspected. However, if I try to use it within my base and derived classes, I get an error which I do not really understand. It seems like it fails to call the to_Json methods (because the error appears if I try to map a DerivedClass-instance (test and test2) to my_json.
I have already tried the example without ordered keys (just by using json = nlohmann::json;) and it works completely fine. The keys in the output are sorted alphabetically and looks like this:
What I am trying to achieve through using the nlohmann fifo_map is to keep the insertion order and the final output therefore should look like this:
Executing the following code outputs two errors:
Please have a look at the following code:
In BaseClass.h:
In DerivedClass.h:
In main.cpp:
The text was updated successfully, but these errors were encountered: