Replies: 2 comments
-
|
If you really want those added directly to the existing object like that, you would need to call The |
Beta Was this translation helpful? Give feedback.
-
|
What you want is a merge — testJson["A"] = "A";
testJson["B"] = "B";
TestStruct myStruct;
testJson.update(nlohmann::json(myStruct));Result: {
"A": "A",
"B": "B",
"field1": 5,
"field2": 10,
"someStr": "Abcd",
"myArray": [0, 0, 0, 0, 0]
}
@gregmarr's (Side note: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Can I append the content of a struct that's serializable via the NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE macro to a json object?
For example:
I would expect the output to be:
The documentation doesn't make it clear how something like that would work.
The example I gave throws an exception. Using
testJson += myStruct;also doesn't work.Beta Was this translation helpful? Give feedback.
All reactions