Boost PropertyTree: How to read json array into?












-1















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?










share|improve this question























  • -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















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?










share|improve this question























  • -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












-1








-1








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?










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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



















  • -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












2 Answers
2






active

oldest

votes


















3














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.






share|improve this answer



















  • 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



















0














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






share|improve this answer

























    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
    });


    }
    });














    draft saved

    draft discarded


















    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









    3














    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.






    share|improve this answer



















    • 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
















    3














    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.






    share|improve this answer



















    • 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














    3












    3








    3







    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.






    share|improve this answer













    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.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    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














    • 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













    0














    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






    share|improve this answer






























      0














      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






      share|improve this answer




























        0












        0








        0







        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






        share|improve this answer















        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







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 19 '18 at 23:47









        RangerRanger

        1,2042925




        1,2042925










        answered Nov 19 '18 at 21:09









        BrianBrian

        1




        1






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            這個網誌中的熱門文章

            Xamarin.form Move up view when keyboard appear

            Post-Redirect-Get with Spring WebFlux and Thymeleaf

            Anylogic : not able to use stopDelay()