Boost logo

Boost Users :

Subject: Re: [Boost-users] [property_tree] Writing comments in JSON format
From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2011-10-07 07:56:06


On 06.09.2011 10:20, Ruediger Berlich wrote:
> Hi there,
>
> by trying it out with a modified debug_settings example, I can see that
> property_tree accepts Javascript ("//") comments inside of the JSON files it
> parses.
>
> I want to find out whether it makes sense to use JSON as an alternative to
> boost.program_options for configuration files. The idea would be to use a
> JavaScript-based GUI to modify or create the configuration files in a
> comfortable way and to use the same files as input for my C++-based
> programs.
>
> As my configuration files are auto-generated by my objects and not everybody
> loves GUIs, I need to be able to add comments to a property_tree object, so
> that they are emitted during a "write_json" call.
>
> The easiest way to add comments to the config files would be to just add a
> "comment" data member. This would indeed be very useful for the JavaScript
> usecase, as comments can be integrated into the GUI / Browser, and would
> still give guidance to those wanting to modify the JSON files with a
> standard editor. However, this does not help me to write things like a
> header, or to add information targeted only at those who modify the files by
> hand. For these I still need to be able to generate "//"-style comments.
>
> > From the documentation I could not find out whether this can be done in a
> standard and portable way. Any pointer would be very welcome!
>
This is not possible with PTree as it is. While I think the ability to
represent and preserve comments would be interesting to quite a few
users, I must admit that I have no idea how to implement such a
functionality in a nice way.

Sebastian


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