Closed Corgile closed 11 months ago
Unexpected '[' and ']', see pic:
minimal code to reproduce:
static nlohmann::json parseProfile(std::string profile) { std::ifstream file(profile); if (not file.is_open()) { INFO(RED("无法打开文件: "), profile); exit(EXIT_FAILURE); } return nlohmann::json::parse(file); } int main() { nlohmann::json profile{parseProfile("/home/brian/Projects/sqlite3-demo/profiles/demo.json")}; std::cout << profile.dump(2); }
expected:
{ "one": 1, "two": "2", "tree": [ 1,2,3 ] }
actual:
[ { "one": 1, "tree": [ 1, 2, 3 ], "two": "2" } ]
No response
ubuntu 2204
v3.11.2
develop
if that's how it actually works, please explain why
See https://json.nlohmann.me/home/faq/#brace-initialization-yields-arrays
Description
Unexpected '[' and ']', see pic:
Reproduction steps
minimal code to reproduce:
Expected vs. actual results
expected:
actual:
Minimal code example
No response
Error messages
No response
Compiler and operating system
ubuntu 2204
Library version
v3.11.2
Validation
develop
branch is used.