Boost PropertyTree: How to read json array into?
So having such json:
{
"config": {
"name": "myconfig",
"servecies": {
"module": [
"file",
"Admin",
"HR"
],
"notModule": "MyNotModule"
}
}
}
How to parse module
array into multimap<string,string>
? and is it possible to find out if module
is an array and notModule is not?
c++ arrays json boost boost-propertytree
add a comment |
So having such json:
{
"config": {
"name": "myconfig",
"servecies": {
"module": [
"file",
"Admin",
"HR"
],
"notModule": "MyNotModule"
}
}
}
How to parse module
array into multimap<string,string>
? and is it possible to find out if module
is an array and notModule is not?
c++ arrays json boost boost-propertytree
-1: You asked this question yesterday, but you apparently didn't like the answer. Boost.PropertyTree is not a general JSON parser; you cannot load any JSON file and build a Boost.PropertyTree from it. If you need a JSON parser, I would suggest finding one.
– Nicol Bolas
Jul 11 '11 at 21:14
add a comment |
So having such json:
{
"config": {
"name": "myconfig",
"servecies": {
"module": [
"file",
"Admin",
"HR"
],
"notModule": "MyNotModule"
}
}
}
How to parse module
array into multimap<string,string>
? and is it possible to find out if module
is an array and notModule is not?
c++ arrays json boost boost-propertytree
So having such json:
{
"config": {
"name": "myconfig",
"servecies": {
"module": [
"file",
"Admin",
"HR"
],
"notModule": "MyNotModule"
}
}
}
How to parse module
array into multimap<string,string>
? and is it possible to find out if module
is an array and notModule is not?
c++ arrays json boost boost-propertytree
c++ arrays json boost boost-propertytree
asked Jul 11 '11 at 18:26
RellaRella
22.7k89311586
22.7k89311586
-1: You asked this question yesterday, but you apparently didn't like the answer. Boost.PropertyTree is not a general JSON parser; you cannot load any JSON file and build a Boost.PropertyTree from it. If you need a JSON parser, I would suggest finding one.
– Nicol Bolas
Jul 11 '11 at 21:14
add a comment |
-1: You asked this question yesterday, but you apparently didn't like the answer. Boost.PropertyTree is not a general JSON parser; you cannot load any JSON file and build a Boost.PropertyTree from it. If you need a JSON parser, I would suggest finding one.
– Nicol Bolas
Jul 11 '11 at 21:14
-1: You asked this question yesterday, but you apparently didn't like the answer. Boost.PropertyTree is not a general JSON parser; you cannot load any JSON file and build a Boost.PropertyTree from it. If you need a JSON parser, I would suggest finding one.
– Nicol Bolas
Jul 11 '11 at 21:14
-1: You asked this question yesterday, but you apparently didn't like the answer. Boost.PropertyTree is not a general JSON parser; you cannot load any JSON file and build a Boost.PropertyTree from it. If you need a JSON parser, I would suggest finding one.
– Nicol Bolas
Jul 11 '11 at 21:14
add a comment |
2 Answers
2
active
oldest
votes
Use a JSON parser. There isn't really anything in C++ that will do all the work for you, you must use an external parser (or roll out your own) and interpret the events as it steps through.
I have had a good experience with jsoncpp, and there are a few others listed on json.org under the C++ section.
1
Boost PropertyTree has JSON parser inside of it. It is not general C++ question its about Boost PropertyTree.
– Rella
Jul 11 '11 at 18:33
add a comment |
The boost property tree includes a JSON parser.
boost::property_tree::json_parser::read_json("file.json", property_tree_root);
parses file.json and puts the root in property_tree_root
.
The children in the property tree will have names, except those that are array elements.
This is essentially the same as: Parse elements from array in json file using boost
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%2f6654704%2fboost-propertytree-how-to-read-json-array-into%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use a JSON parser. There isn't really anything in C++ that will do all the work for you, you must use an external parser (or roll out your own) and interpret the events as it steps through.
I have had a good experience with jsoncpp, and there are a few others listed on json.org under the C++ section.
1
Boost PropertyTree has JSON parser inside of it. It is not general C++ question its about Boost PropertyTree.
– Rella
Jul 11 '11 at 18:33
add a comment |
Use a JSON parser. There isn't really anything in C++ that will do all the work for you, you must use an external parser (or roll out your own) and interpret the events as it steps through.
I have had a good experience with jsoncpp, and there are a few others listed on json.org under the C++ section.
1
Boost PropertyTree has JSON parser inside of it. It is not general C++ question its about Boost PropertyTree.
– Rella
Jul 11 '11 at 18:33
add a comment |
Use a JSON parser. There isn't really anything in C++ that will do all the work for you, you must use an external parser (or roll out your own) and interpret the events as it steps through.
I have had a good experience with jsoncpp, and there are a few others listed on json.org under the C++ section.
Use a JSON parser. There isn't really anything in C++ that will do all the work for you, you must use an external parser (or roll out your own) and interpret the events as it steps through.
I have had a good experience with jsoncpp, and there are a few others listed on json.org under the C++ section.
answered Jul 11 '11 at 18:30
Andrew RasmussenAndrew Rasmussen
10.5k42969
10.5k42969
1
Boost PropertyTree has JSON parser inside of it. It is not general C++ question its about Boost PropertyTree.
– Rella
Jul 11 '11 at 18:33
add a comment |
1
Boost PropertyTree has JSON parser inside of it. It is not general C++ question its about Boost PropertyTree.
– Rella
Jul 11 '11 at 18:33
1
1
Boost PropertyTree has JSON parser inside of it. It is not general C++ question its about Boost PropertyTree.
– Rella
Jul 11 '11 at 18:33
Boost PropertyTree has JSON parser inside of it. It is not general C++ question its about Boost PropertyTree.
– Rella
Jul 11 '11 at 18:33
add a comment |
The boost property tree includes a JSON parser.
boost::property_tree::json_parser::read_json("file.json", property_tree_root);
parses file.json and puts the root in property_tree_root
.
The children in the property tree will have names, except those that are array elements.
This is essentially the same as: Parse elements from array in json file using boost
add a comment |
The boost property tree includes a JSON parser.
boost::property_tree::json_parser::read_json("file.json", property_tree_root);
parses file.json and puts the root in property_tree_root
.
The children in the property tree will have names, except those that are array elements.
This is essentially the same as: Parse elements from array in json file using boost
add a comment |
The boost property tree includes a JSON parser.
boost::property_tree::json_parser::read_json("file.json", property_tree_root);
parses file.json and puts the root in property_tree_root
.
The children in the property tree will have names, except those that are array elements.
This is essentially the same as: Parse elements from array in json file using boost
The boost property tree includes a JSON parser.
boost::property_tree::json_parser::read_json("file.json", property_tree_root);
parses file.json and puts the root in property_tree_root
.
The children in the property tree will have names, except those that are array elements.
This is essentially the same as: Parse elements from array in json file using boost
edited Nov 19 '18 at 23:47
RangerRanger
1,2042925
1,2042925
answered Nov 19 '18 at 21:09
BrianBrian
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%2f6654704%2fboost-propertytree-how-to-read-json-array-into%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
-1: You asked this question yesterday, but you apparently didn't like the answer. Boost.PropertyTree is not a general JSON parser; you cannot load any JSON file and build a Boost.PropertyTree from it. If you need a JSON parser, I would suggest finding one.
– Nicol Bolas
Jul 11 '11 at 21:14