I'am having some problems with boost json in c++
I see that have a lot of questions very similar to mine, but I don´t see any solutions that fit with my problem.
I' am trying to create a JSON with boost library with the below structure:
{
"event_date": "2018-06-11T09:35:48.867Z",
"event_log": "2018-06-11 09:35:43,253 - recycler [TRACE]: Running recycler::WITHDRAW",
"cassettes": [
{
"value" : "0",
"currency": "BRL",
"CDMType" : "WFS_CDM_TYPEREJECTCASSETTE",
"lppPhysical" : [
{
"positionName" : "BIN1A",
"count" : "3"
}
]
},
{.....},{.....}
]
}
Below we will have the code that I have now:
boost::property_tree::ptree children, children2, child, child1, child2, child3, child4, child5, cassettes;
child1.put("value", "cash_unit->ulValues");
child2.put("currency", "std::string(cash_unit->cCurrencyID).substr(0, 3)");
child3.put("CDMType", "cash_unit->usType");
child4.put("lppPhysical.positionName", "ph_unit->lpPhysicalPositionName");
child5.put("lppPhysical.count", "cash_unit->ulCount");
cassettes.put("event_date", "2018-06-11T09:35:48.867Z");
cassettes.put("event_log", "2018-06-11 09:35:43,253 - recycler [TRACE]: Running recycler::WITHDRAW");
children.push_back(std::make_pair("", child1));
children.push_back(std::make_pair("", child2));
children.push_back(std::make_pair("", child3));
children2.push_back(std::make_pair("", child4));
children2.push_back(std::make_pair("", child5));
cassettes.add_child("cassettes", children);
write_json("C:\Temp\test.json", cassettes);`
Summarizing, I'm having difficulties to put an array of objects inside of an array of objects.
c++ arrays object boost
add a comment |
I see that have a lot of questions very similar to mine, but I don´t see any solutions that fit with my problem.
I' am trying to create a JSON with boost library with the below structure:
{
"event_date": "2018-06-11T09:35:48.867Z",
"event_log": "2018-06-11 09:35:43,253 - recycler [TRACE]: Running recycler::WITHDRAW",
"cassettes": [
{
"value" : "0",
"currency": "BRL",
"CDMType" : "WFS_CDM_TYPEREJECTCASSETTE",
"lppPhysical" : [
{
"positionName" : "BIN1A",
"count" : "3"
}
]
},
{.....},{.....}
]
}
Below we will have the code that I have now:
boost::property_tree::ptree children, children2, child, child1, child2, child3, child4, child5, cassettes;
child1.put("value", "cash_unit->ulValues");
child2.put("currency", "std::string(cash_unit->cCurrencyID).substr(0, 3)");
child3.put("CDMType", "cash_unit->usType");
child4.put("lppPhysical.positionName", "ph_unit->lpPhysicalPositionName");
child5.put("lppPhysical.count", "cash_unit->ulCount");
cassettes.put("event_date", "2018-06-11T09:35:48.867Z");
cassettes.put("event_log", "2018-06-11 09:35:43,253 - recycler [TRACE]: Running recycler::WITHDRAW");
children.push_back(std::make_pair("", child1));
children.push_back(std::make_pair("", child2));
children.push_back(std::make_pair("", child3));
children2.push_back(std::make_pair("", child4));
children2.push_back(std::make_pair("", child5));
cassettes.add_child("cassettes", children);
write_json("C:\Temp\test.json", cassettes);`
Summarizing, I'm having difficulties to put an array of objects inside of an array of objects.
c++ arrays object boost
Hi Allan Paz, from your question, it is not clear what the problem is; could you specify what goes wrong? (error message, wrong output...) so it is easier for other people to answer your question?
– Silmathoron
Nov 21 '18 at 19:31
Sure, I'm having difficulties to insert an array (the lppPhysical) inside the cassettes (array of objects) like the above structure. My code only inserts the IppPhysical as an object in the cassettes.
– Allan Paz
Nov 22 '18 at 12:24
This is still unclear... Am I then correct in assuming that the structure you posted is your current output and that it is not what you want? If so could you please post the desired output?
– Silmathoron
Nov 22 '18 at 13:40
The mentioned structure is the correct one(mock), I need to translate this structure using boost library, but I am having difficulties on the lppPhysical part(Insert an array of objects as a child of the cassettes, which is an array of objects.
– Allan Paz
Nov 22 '18 at 13:50
add a comment |
I see that have a lot of questions very similar to mine, but I don´t see any solutions that fit with my problem.
I' am trying to create a JSON with boost library with the below structure:
{
"event_date": "2018-06-11T09:35:48.867Z",
"event_log": "2018-06-11 09:35:43,253 - recycler [TRACE]: Running recycler::WITHDRAW",
"cassettes": [
{
"value" : "0",
"currency": "BRL",
"CDMType" : "WFS_CDM_TYPEREJECTCASSETTE",
"lppPhysical" : [
{
"positionName" : "BIN1A",
"count" : "3"
}
]
},
{.....},{.....}
]
}
Below we will have the code that I have now:
boost::property_tree::ptree children, children2, child, child1, child2, child3, child4, child5, cassettes;
child1.put("value", "cash_unit->ulValues");
child2.put("currency", "std::string(cash_unit->cCurrencyID).substr(0, 3)");
child3.put("CDMType", "cash_unit->usType");
child4.put("lppPhysical.positionName", "ph_unit->lpPhysicalPositionName");
child5.put("lppPhysical.count", "cash_unit->ulCount");
cassettes.put("event_date", "2018-06-11T09:35:48.867Z");
cassettes.put("event_log", "2018-06-11 09:35:43,253 - recycler [TRACE]: Running recycler::WITHDRAW");
children.push_back(std::make_pair("", child1));
children.push_back(std::make_pair("", child2));
children.push_back(std::make_pair("", child3));
children2.push_back(std::make_pair("", child4));
children2.push_back(std::make_pair("", child5));
cassettes.add_child("cassettes", children);
write_json("C:\Temp\test.json", cassettes);`
Summarizing, I'm having difficulties to put an array of objects inside of an array of objects.
c++ arrays object boost
I see that have a lot of questions very similar to mine, but I don´t see any solutions that fit with my problem.
I' am trying to create a JSON with boost library with the below structure:
{
"event_date": "2018-06-11T09:35:48.867Z",
"event_log": "2018-06-11 09:35:43,253 - recycler [TRACE]: Running recycler::WITHDRAW",
"cassettes": [
{
"value" : "0",
"currency": "BRL",
"CDMType" : "WFS_CDM_TYPEREJECTCASSETTE",
"lppPhysical" : [
{
"positionName" : "BIN1A",
"count" : "3"
}
]
},
{.....},{.....}
]
}
Below we will have the code that I have now:
boost::property_tree::ptree children, children2, child, child1, child2, child3, child4, child5, cassettes;
child1.put("value", "cash_unit->ulValues");
child2.put("currency", "std::string(cash_unit->cCurrencyID).substr(0, 3)");
child3.put("CDMType", "cash_unit->usType");
child4.put("lppPhysical.positionName", "ph_unit->lpPhysicalPositionName");
child5.put("lppPhysical.count", "cash_unit->ulCount");
cassettes.put("event_date", "2018-06-11T09:35:48.867Z");
cassettes.put("event_log", "2018-06-11 09:35:43,253 - recycler [TRACE]: Running recycler::WITHDRAW");
children.push_back(std::make_pair("", child1));
children.push_back(std::make_pair("", child2));
children.push_back(std::make_pair("", child3));
children2.push_back(std::make_pair("", child4));
children2.push_back(std::make_pair("", child5));
cassettes.add_child("cassettes", children);
write_json("C:\Temp\test.json", cassettes);`
Summarizing, I'm having difficulties to put an array of objects inside of an array of objects.
c++ arrays object boost
c++ arrays object boost
edited Nov 21 '18 at 20:00
Silmathoron
1,0861921
1,0861921
asked Nov 21 '18 at 19:20
Allan PazAllan Paz
1
1
Hi Allan Paz, from your question, it is not clear what the problem is; could you specify what goes wrong? (error message, wrong output...) so it is easier for other people to answer your question?
– Silmathoron
Nov 21 '18 at 19:31
Sure, I'm having difficulties to insert an array (the lppPhysical) inside the cassettes (array of objects) like the above structure. My code only inserts the IppPhysical as an object in the cassettes.
– Allan Paz
Nov 22 '18 at 12:24
This is still unclear... Am I then correct in assuming that the structure you posted is your current output and that it is not what you want? If so could you please post the desired output?
– Silmathoron
Nov 22 '18 at 13:40
The mentioned structure is the correct one(mock), I need to translate this structure using boost library, but I am having difficulties on the lppPhysical part(Insert an array of objects as a child of the cassettes, which is an array of objects.
– Allan Paz
Nov 22 '18 at 13:50
add a comment |
Hi Allan Paz, from your question, it is not clear what the problem is; could you specify what goes wrong? (error message, wrong output...) so it is easier for other people to answer your question?
– Silmathoron
Nov 21 '18 at 19:31
Sure, I'm having difficulties to insert an array (the lppPhysical) inside the cassettes (array of objects) like the above structure. My code only inserts the IppPhysical as an object in the cassettes.
– Allan Paz
Nov 22 '18 at 12:24
This is still unclear... Am I then correct in assuming that the structure you posted is your current output and that it is not what you want? If so could you please post the desired output?
– Silmathoron
Nov 22 '18 at 13:40
The mentioned structure is the correct one(mock), I need to translate this structure using boost library, but I am having difficulties on the lppPhysical part(Insert an array of objects as a child of the cassettes, which is an array of objects.
– Allan Paz
Nov 22 '18 at 13:50
Hi Allan Paz, from your question, it is not clear what the problem is; could you specify what goes wrong? (error message, wrong output...) so it is easier for other people to answer your question?
– Silmathoron
Nov 21 '18 at 19:31
Hi Allan Paz, from your question, it is not clear what the problem is; could you specify what goes wrong? (error message, wrong output...) so it is easier for other people to answer your question?
– Silmathoron
Nov 21 '18 at 19:31
Sure, I'm having difficulties to insert an array (the lppPhysical) inside the cassettes (array of objects) like the above structure. My code only inserts the IppPhysical as an object in the cassettes.
– Allan Paz
Nov 22 '18 at 12:24
Sure, I'm having difficulties to insert an array (the lppPhysical) inside the cassettes (array of objects) like the above structure. My code only inserts the IppPhysical as an object in the cassettes.
– Allan Paz
Nov 22 '18 at 12:24
This is still unclear... Am I then correct in assuming that the structure you posted is your current output and that it is not what you want? If so could you please post the desired output?
– Silmathoron
Nov 22 '18 at 13:40
This is still unclear... Am I then correct in assuming that the structure you posted is your current output and that it is not what you want? If so could you please post the desired output?
– Silmathoron
Nov 22 '18 at 13:40
The mentioned structure is the correct one(mock), I need to translate this structure using boost library, but I am having difficulties on the lppPhysical part(Insert an array of objects as a child of the cassettes, which is an array of objects.
– Allan Paz
Nov 22 '18 at 13:50
The mentioned structure is the correct one(mock), I need to translate this structure using boost library, but I am having difficulties on the lppPhysical part(Insert an array of objects as a child of the cassettes, which is an array of objects.
– Allan Paz
Nov 22 '18 at 13:50
add a comment |
1 Answer
1
active
oldest
votes
Finally found a solution to my case, it's pretty simple but was hard to find since I am not too familiar with this library.
//LppPhysical insertion
lppPhysicalInfo.put("positionName", ph_unit->lpPhysicalPositionName);
lppPhysicalInfo.put("count", cash_unit->ulCount);
lppPhysical.push_back(std::make_pair("", lppPhysicalInfo));
//Cassettes insertions
cassettesInfo.put("value", cash_unit->ulValues);
cassettesInfo.put("currency", std::string(cash_unit->cCurrencyID).substr(0, 3));
cassettesInfo.put("CDMType", cash_unit->usType);
cassettesInfo.add_child("lppPhysical", lppPhysical.get_child(""));
cassettes.push_back(std::make_pair("", cassettesInfo));
//External information insertion
arquivo.put("event_date", "DateValue");
arquivo.put("event_log", "LogValue");
arquivo.add_child("cassettes", cassettes);
//Json creator
write_json("C:\Temp\assassino.json", arquivo);
On the lppPhysical I just make a pair with all its content and on the Cassettes' insertion I just added the lppPhysical as a child of the cassettes and that's it. Now the lppPhysical is an array of object insde the Cassettes which is also an array of objects
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419171%2fiam-having-some-problems-with-boost-json-in-c%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Finally found a solution to my case, it's pretty simple but was hard to find since I am not too familiar with this library.
//LppPhysical insertion
lppPhysicalInfo.put("positionName", ph_unit->lpPhysicalPositionName);
lppPhysicalInfo.put("count", cash_unit->ulCount);
lppPhysical.push_back(std::make_pair("", lppPhysicalInfo));
//Cassettes insertions
cassettesInfo.put("value", cash_unit->ulValues);
cassettesInfo.put("currency", std::string(cash_unit->cCurrencyID).substr(0, 3));
cassettesInfo.put("CDMType", cash_unit->usType);
cassettesInfo.add_child("lppPhysical", lppPhysical.get_child(""));
cassettes.push_back(std::make_pair("", cassettesInfo));
//External information insertion
arquivo.put("event_date", "DateValue");
arquivo.put("event_log", "LogValue");
arquivo.add_child("cassettes", cassettes);
//Json creator
write_json("C:\Temp\assassino.json", arquivo);
On the lppPhysical I just make a pair with all its content and on the Cassettes' insertion I just added the lppPhysical as a child of the cassettes and that's it. Now the lppPhysical is an array of object insde the Cassettes which is also an array of objects
add a comment |
Finally found a solution to my case, it's pretty simple but was hard to find since I am not too familiar with this library.
//LppPhysical insertion
lppPhysicalInfo.put("positionName", ph_unit->lpPhysicalPositionName);
lppPhysicalInfo.put("count", cash_unit->ulCount);
lppPhysical.push_back(std::make_pair("", lppPhysicalInfo));
//Cassettes insertions
cassettesInfo.put("value", cash_unit->ulValues);
cassettesInfo.put("currency", std::string(cash_unit->cCurrencyID).substr(0, 3));
cassettesInfo.put("CDMType", cash_unit->usType);
cassettesInfo.add_child("lppPhysical", lppPhysical.get_child(""));
cassettes.push_back(std::make_pair("", cassettesInfo));
//External information insertion
arquivo.put("event_date", "DateValue");
arquivo.put("event_log", "LogValue");
arquivo.add_child("cassettes", cassettes);
//Json creator
write_json("C:\Temp\assassino.json", arquivo);
On the lppPhysical I just make a pair with all its content and on the Cassettes' insertion I just added the lppPhysical as a child of the cassettes and that's it. Now the lppPhysical is an array of object insde the Cassettes which is also an array of objects
add a comment |
Finally found a solution to my case, it's pretty simple but was hard to find since I am not too familiar with this library.
//LppPhysical insertion
lppPhysicalInfo.put("positionName", ph_unit->lpPhysicalPositionName);
lppPhysicalInfo.put("count", cash_unit->ulCount);
lppPhysical.push_back(std::make_pair("", lppPhysicalInfo));
//Cassettes insertions
cassettesInfo.put("value", cash_unit->ulValues);
cassettesInfo.put("currency", std::string(cash_unit->cCurrencyID).substr(0, 3));
cassettesInfo.put("CDMType", cash_unit->usType);
cassettesInfo.add_child("lppPhysical", lppPhysical.get_child(""));
cassettes.push_back(std::make_pair("", cassettesInfo));
//External information insertion
arquivo.put("event_date", "DateValue");
arquivo.put("event_log", "LogValue");
arquivo.add_child("cassettes", cassettes);
//Json creator
write_json("C:\Temp\assassino.json", arquivo);
On the lppPhysical I just make a pair with all its content and on the Cassettes' insertion I just added the lppPhysical as a child of the cassettes and that's it. Now the lppPhysical is an array of object insde the Cassettes which is also an array of objects
Finally found a solution to my case, it's pretty simple but was hard to find since I am not too familiar with this library.
//LppPhysical insertion
lppPhysicalInfo.put("positionName", ph_unit->lpPhysicalPositionName);
lppPhysicalInfo.put("count", cash_unit->ulCount);
lppPhysical.push_back(std::make_pair("", lppPhysicalInfo));
//Cassettes insertions
cassettesInfo.put("value", cash_unit->ulValues);
cassettesInfo.put("currency", std::string(cash_unit->cCurrencyID).substr(0, 3));
cassettesInfo.put("CDMType", cash_unit->usType);
cassettesInfo.add_child("lppPhysical", lppPhysical.get_child(""));
cassettes.push_back(std::make_pair("", cassettesInfo));
//External information insertion
arquivo.put("event_date", "DateValue");
arquivo.put("event_log", "LogValue");
arquivo.add_child("cassettes", cassettes);
//Json creator
write_json("C:\Temp\assassino.json", arquivo);
On the lppPhysical I just make a pair with all its content and on the Cassettes' insertion I just added the lppPhysical as a child of the cassettes and that's it. Now the lppPhysical is an array of object insde the Cassettes which is also an array of objects
answered Nov 23 '18 at 13:58
Allan PazAllan Paz
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419171%2fiam-having-some-problems-with-boost-json-in-c%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Hi Allan Paz, from your question, it is not clear what the problem is; could you specify what goes wrong? (error message, wrong output...) so it is easier for other people to answer your question?
– Silmathoron
Nov 21 '18 at 19:31
Sure, I'm having difficulties to insert an array (the lppPhysical) inside the cassettes (array of objects) like the above structure. My code only inserts the IppPhysical as an object in the cassettes.
– Allan Paz
Nov 22 '18 at 12:24
This is still unclear... Am I then correct in assuming that the structure you posted is your current output and that it is not what you want? If so could you please post the desired output?
– Silmathoron
Nov 22 '18 at 13:40
The mentioned structure is the correct one(mock), I need to translate this structure using boost library, but I am having difficulties on the lppPhysical part(Insert an array of objects as a child of the cassettes, which is an array of objects.
– Allan Paz
Nov 22 '18 at 13:50