You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the issue you have?
The example in README.md to explicitly construct an array does not work. Maybe a typo/oversight?
// a way to express an _array_ of key/value pairs [["currency", "USD"], ["value", 42.99]]
json array_not_object = { json::array({"currency", "USD"}), json::array({"value", 42.99}) };
Please describe the steps to reproduce the issue. Can you provide a small but working code example?
using json = nlohmann::json;
// The original example prints: {"currency":"USD","value":42.99}
json array_not_object = { json::array({"currency", "USD"}), json::array({"value", 42.99}) };
std::cout << array_not_object.dump() << std::endl;
// This seems to work correctly. It prints: [["currency","USD"],["value",42.99]]
json array_not_object_corrected = json::array({ { "currency", "USD" }, { "value", 42.99 } });
std::cout << array_not_object_corrected.dump() << std::endl;
What is the expected behavior?
Constructs an JSON array, i.e. [["currency", "USD"], ["value", 42.99]]
And what is the actual behavior instead?
Constructs an JSON object, {"currency":"USD","value":42.99}
Which compiler and operating system are you using? Is it a supported compiler?
Windows + VS2015. Yes, it is.
Did you use a released version of the library or the version from the develop branch?
Master branch
The text was updated successfully, but these errors were encountered:
Thanks for reporting. I can confirm the behavior for all versions of the library - from 1.0.0-rc1 to the develop version. This is an oversight from me - the code in the README is indeed part of a unit test, but we never checked the results, but only made sure the code does compile.
The example in the documentation on how to "force" an array of arrays was wrong since the first release. Fixed the documentation and added checks for the README unit tests.
Bug Report
The example in README.md to explicitly construct an array does not work. Maybe a typo/oversight?
What is the expected behavior?
Constructs an JSON array, i.e. [["currency", "USD"], ["value", 42.99]]
And what is the actual behavior instead?
Constructs an JSON object, {"currency":"USD","value":42.99}
Which compiler and operating system are you using? Is it a supported compiler?
Windows + VS2015. Yes, it is.
Did you use a released version of the library or the version from the
develop
branch?Master branch
The text was updated successfully, but these errors were encountered: