{ "subject": "Re: JSON-RPC password", "content": { "format": "html", "body": "<div class=\"post\">I was researching config file formats, here's a comparison.<br/><br/>YAML is massive. &nbsp;I'm not sure there's a lightweight easy to build library we can integrate into our project. &nbsp;Seems overkill.<br/><br/>JSON is tempting and I'm inclined to like it, but two main sticking points:<br/>1) No comments! &nbsp;How can you have a config file where you can't comment out a line to disable it?<br/>2) Not very user friendly to have to \"quote\" all the strings, including the keys, and also have to remember the comma at the end of lines.<br/>{<br/>&nbsp;&nbsp; &nbsp;\"key\" : \"value\",<br/>}<br/><br/>I suppose we could easily preprocess JSON reading the config file one line at a time, truncate the lines at any # character (and/or \"//\"?), concatenate them into a string and pass it to JSON, so you could go:<br/># comment<br/>\"key\" : \"value\", &nbsp; # still have to remember the comma <br/>\"key2\" : \"value\", &nbsp; // comment like this or both<br/><br/>Boost has boost::program_options.<br/><br/>We could read lines ourselves and feed them into a map&lt;string, string&gt; mapConfig.<br/><br/>while (!eof)<br/>&nbsp;&nbsp;read line<br/>&nbsp;&nbsp;if '#' found, truncate line<br/>&nbsp;&nbsp;split line at first ':' -&gt; key, value<br/>&nbsp;&nbsp;mapConfig.insert(key, value)<br/><br/>If we use the syntax:<br/># comment<br/>key : value<br/><br/>...and don't allow whitespace indenting before the keys, I guess we would be a subset of YAML and could switch to YAML someday if we need more complexity. <br/><br/>If we go with self parsed, that doesn't mean we can't use JSON on particular parameter values as needed. &nbsp;If an option needs a list or more structured data, it could always parse its value as json:<br/>key : [\"item1\", \"item2\", \"item3\"]<br/><br/>Although it has to be all on one line then.<br/><br/>I guess I'm leaning towards self parsed mapConfig:<br/># comment<br/>key : value<br/></div>" }, "source": { "name": "Bitcoin Forum", "url": "https://bitcointalk.org/index.php?topic=461.msg4646#msg4646" }, "date": "2010-07-21T05:51:34Z" }
Inscription number 18,209,260
Genesis block 799,364
File type json
File size 2.61 KB
Creation date