Skip to content

Serialization of std::map<std::pair<std::string, std::string>, std::vector<std::string>> is inconsistent? #4013

Answered by EddieDover
EddieDover asked this question in Q&A
Discussion options

You must be logged in to vote

I think the actual issue here stems from Item 5b on https://json.nlohmann.me/api/basic_json/basic_json/

If the list consists of pairs whose first element is a string, a JSON object value is created where the first elements of the pairs are treated as keys and the second elements are as values.

Since the keys are pairs of strings and the value is a string vector, if it has exactly 2 items, then it fulfills the above requirement and is treated differently.

I intend to switch to another JSON library but, in the meanwhile, I simply added code during my JSON Read/Write functions that adds/removes a 3rd temporary item to any of the value vectors that only have two items.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by EddieDover
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants