std::pair treated as an array instead of key-value in std::vector<std::pair<>>
#1520
Labels
confirmed
state: stale
the issue has not been updated in a while and will be closed automatically soon unless it is updated
What is the issue you have?
I have a variable with std::vector<std::pair<std::string, std::string>> that cannot be deserialised by nlohmann::json.
Please describe the steps to reproduce the issue. Can you provide a small but working code example?
JSON: { "options": [{"video_size": ""}, {"framerate": "0"}, {"vcodec": ""}] }
std::vector<std::pair<std::string,std::string>> m_Options;
Non-working Code:
j["options].get_to(m_Options);
Working code:
What is the expected behavior?
Should be able to deserialise to an STL type automatically
And what is the actual behavior instead?
Failed to deserialise because wrong type
Which compiler and operating system are you using? Is it a supported compiler?
MSVC 2017
Did you use a released version of the library or the version from the
develop
branch?V3.2.0 - V3.5.0 exhibit this issue
Notes: When serialising m_Options I get:
JSON: { "options":[["video_size",""],["framerate","0"],["vcodec",""]] }
Basically, it treats a std::pair as an array with two elements, rather than a key-value pair.
The text was updated successfully, but these errors were encountered: