Boost logo

Boost :

Subject: [boost] [property_tree] Issue: erase is corrupting the tree
From: lukas.exler_at_[hidden]
Date: 2017-06-05 13:08:26


I have following JSON structure loaded into boost::property_tree:
{
    "animals" : ["fox","dog","cat"]
}

I'm trying to delete the second item from the array by:
        auto assoc_it = loadedJSON.find("animals");
        auto it = loadedJSON.to_iterator(assoc_it);
        it = it->second.begin();
        it++; // move to second item
        loadedJSON.erase(it);

After this, when I try to use boost::property_tree::write_json to write the JSON back the app crashes. Do I use the property tree in a wrong way, or is there a bug?

Thanks,
Lukas.

_______________________________________________

This message is for information purposes only, it is not a recommendation, advice, offer or solicitation to buy or sell a product or service nor an official confirmation of any transaction. It is directed at persons who are professionals and is not intended for retail customer use. Intended for recipient only. This message is subject to the terms at: www.barclays.com/emaildisclaimer.

For important disclosures, please see: www.barclays.com/salesandtradingdisclaimer regarding market commentary from Barclays Sales and/or Trading, who are active market participants; and in respect of Barclays Research, including disclosures relating to specific issuers, please see http://publicresearch.barclays.com.

_______________________________________________


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk