0

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?

Rella
  • 65,003
  • 109
  • 363
  • 636
  • -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 Answers2

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.

Andrew Rasmussen
  • 14,912
  • 10
  • 45
  • 81
  • 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

RangerRanger
  • 2,455
  • 2
  • 16
  • 36
Brian
  • 1