We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe what you want to achieve. I want to add json type object to other json object
json
Describe what you tried.
std::vector<json> vec; ... // fill vec json all; for (auto obj : vec) all["inside"].emplace_back(obj):
Describe which system (OS, compiler) you are using. VS 2019
Describe which version of the library you are using (release version, develop branch). Latest from the Github (master)
PROBLEM: but after emplace_back / push_back the all json object is still empty
emplace_back
push_back
all
The text was updated successfully, but these errors were encountered:
I'm not sure I follow. Can you explain what you get and what you were expecting to get?
Sorry, something went wrong.
Are you sure vec is filled correctly? I tested the following demo code on VS 2019
vec
#include <iostream> #include <vector> #include "json.hpp" int main() { std::vector<nlohmann::json> vec; vec.push_back({ "item1", 1 }); vec.push_back({ "item2", 2 }); vec.push_back({ "item3", 3 }); nlohmann::json all; for (auto obj : vec) all["inside"].emplace_back(obj); std::cout << all.dump() << std::endl; return 0; }
and it outputs the following as expected:
{"inside":[["item1",1],["item2",2],["item3",3]]}
@dvfdr43 Did @nickaein 's answer help you?
Solved, thank you
No branches or pull requests
Describe what you want to achieve.
I want to add
json
type object to otherjson
objectDescribe what you tried.
Describe which system (OS, compiler) you are using.
VS 2019
Describe which version of the library you are using (release version, develop branch).
Latest from the Github (master)
PROBLEM:
but after
emplace_back
/push_back
theall
json object is still emptyThe text was updated successfully, but these errors were encountered: