I have been trying to use the put and erase methods in boost's property tree library with very limited success. I have tried to go through the documentation but it seems really esoteric with no real example to demonstrate. This is what I would like to do -

I have a json object. I look for a particular key (call it "title") and extract the corresponding value (call it "Eric Clapton"), do something with "Eric Clapton" (say change it to "ec") insert it in the place of the old value. Now, should I do an "erase" to remove the previous entry and then "put" the new pair? Will "put" replace the old value?

    void doSomething(const ptree& node)
    {
        ...
        BOOST_FOREACH(const ptree::value_type& child, node.get_child("artists"))
        {
            string text = child.second.get<string>("title");
            // do something to the text to give text2
            child.second.put("title", text2);
        }
        ...
    }


The above code gives an error which is equally hard to understand. I was hoping someone would shed some light.

thanks
Sashidhar