Boost logo

Boost Users :

Subject: [Boost-users] JSON Property file reader compile problem
From: Scott Smith (ssmith_at_[hidden])
Date: 2011-08-09 21:34:45


I'm trying to use the boost property tree to read a json file. I'm using 1.46 on gcc 4.6 (Fedora 15). I'm also running on Eclipse (Indigo) which is relevant for something I mention below.

Here's the issue . I have a JSON file which has an array of parameters which looks something like:
{
"config":
{
                "modules":
                [
                                {
                                                "name": "somename0",
                                                "param1": "someparam",
                                                "param2":"someotherparm"
                                },
                                {
                                                "name": "somename1",
                                                "param1": "someparam",
                                                "param2":"someotherparm"
                                },
                                {
                                                "name": "somename2",
                                                "param1": "someparam",
                                                "param2":"someotherparm"
                                }
                ]
}
}

So, I wrote the following code (Note that I can't use boost:FOR_EACH because of some bug in eclipse (#332278) which causes an error-or so I believe):

                ptree v = pt.get<ptree>("config.modules");
                for (ptree::iterator it = v.begin() ; it != v.end ; ++it)
                {
                                ptree module = ???;
                }

The first two lines seem to compile fine. I'm assuming that what I get from v is the "root" ptree (the parent) for the various "modules" objects and that the iterator will walk through them. However, I've tried all sorts of things trying to get at the module data (e.g., it->second, (*it)->second, ...) and clearly I don't know what it is I need to tell the compiler I want. All I get are compile errors. The compiler is giving me no hints as to what I need to tell it.

Can someone tell me what I'm missing here?

Thanks

Scott



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net