When copying a fifo_json to another fifo_json and appending values for new keys, different keys present in the original fifo_json are being modified instead of new keys being created.
fifo_json j1;
j1["Ender"] = "The Formics are intelligent";
j1["Amstrong"] = "Walking on the moon";
j1["Fairytale"] = "Once upon a time";
cout << setw(2) << j1 << endl << endl;
fifo_json jj(j1);
// fifo_json &jj = j1; // this works fine (though perhaps because it doesn't copy)
jj["My settings"] = {};
jj["My settings"]["Darwin"] = "Evolution of Species";
jj["Abracadabra"] = "Ta-Da";
cout << setw(2) << jj << endl;
The expected result should be:
{
"Ender": "The Formics are intelligent",
"Amstrong": "Walking on the moon",
"Fairytale": "Once upon a time"
}
{
"Ender": "The Formics are intelligent",
"Amstrong": "Walking on the moon",
"Fairytale": "Once upon a time",
"My settings": {
"Darwin": "Evolution of Species"
},
"Abracadabra": "Ta-Da"
}
But instead I get this:
the output is:
{
"Ender": "The Formics are intelligent",
"Amstrong": "Walking on the moon",
"Fairytale": "Once upon a time"
}
{
"Ender": {
"Darwin": "Evolution of Species"
},
"Amstrong": "Walking on the moon",
"Fairytale": "Ta-Da"
}
I'm running this on the following system:
- OS: Ubuntu 16.04.1
- g++ (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609
- using c++11 standard
- json version used is: 3.3.0
And I'm using the following definitions :
// A workaround to give to use fifo_map as map, we are just ignoring the 'less' compare
template<class K, class V, class dummy_compare, class A>
using my_fifo_map = nlohmann::fifo_map<K, V, nlohmann::fifo_map_compare<K>, A>;
using fifo_json = nlohmann::basic_json<my_fifo_map>;
using json = nlohmann::json;
When copying a fifo_json to another fifo_json and appending values for new keys, different keys present in the original fifo_json are being modified instead of new keys being created.
The expected result should be:
But instead I get this:
the output is:
I'm running this on the following system:
And I'm using the following definitions :