August 14, 2015
On Friday, 14 August 2015 at 15:11:41 UTC, Steven Schveighoffer wrote:
> And that would be possible here. JSON file format says nothing about how the data is stored in your library. But again, not important.

It isn't important since JSON is not too good as a config file format, but it is important when considering other formats.

When you read a JSON file into Python or Javascript and write it back all dictionary objects will be restructured. For instance, when a tool reads a config file and removes attributes it is desirable that removed attributes are commented out.

With JSON you would have to hack around it like this:

[ {fieldname1:value1}, {fieldname2:value2} ]

Which is ugly.

I think it would be nice if all D tooling standardized on YAML and provided a convenient DOM for it. It is used quite a lot and editors have support for it.

August 14, 2015
On Friday, 14 August 2015 at 15:29:12 UTC, Ola Fosheim Grøstad wrote:
> On Friday, 14 August 2015 at 15:11:41 UTC, Steven Schveighoffer wrote:
>> And that would be possible here. JSON file format says nothing about how the data is stored in your library. But again, not important.
>
> It isn't important since JSON is not too good as a config file format, but it is important when considering other formats.
>
> When you read a JSON file into Python or Javascript and write it back all dictionary objects will be restructured. For instance, when a tool reads a config file and removes attributes it is desirable that removed attributes are commented out.
>
> With JSON you would have to hack around it like this:
>
> [ {fieldname1:value1}, {fieldname2:value2} ]
>
> Which is ugly.
>
> I think it would be nice if all D tooling standardized on YAML and provided a convenient DOM for it. It is used quite a lot and editors have support for it.

It doesn't matter what you think of JSON.

JSON is widely used an needed in the standard lib. PERIOD.
August 14, 2015
On Friday, 14 August 2015 at 17:31:02 UTC, deadalnix wrote:
> JSON is widely used an needed in the standard lib. PERIOD.

The discussion was about suitability as a standard config file format for D not whether it should be in the standard lib. JSON, XML and YAML all belong in a standard lib.

August 14, 2015
On 8/14/15 1:30 PM, deadalnix wrote:
> It doesn't matter what you think of JSON.
>
> JSON is widely used an needed in the standard lib. PERIOD.

I think you are missing that this sub-discussion is about using json to replace dmd configuration file.

-Steve
August 14, 2015
On 8/14/2015 5:51 AM, Andrei Alexandrescu wrote:
> On 8/13/15 8:16 PM, Walter Bright wrote:
>> On 8/13/2015 5:22 AM, CraigDillabaugh wrote:
>>> No configuration file should be in a format that doesn't support
>>> comments.
>>
>> [ "comment" : "and you thought it couldn't have comments!" ]

Should be { }, not [ ]


> There can't be two comments with the same key though. -- Andrei

The Json spec doesn't say that - it doesn't specify any semantic meaning.

August 14, 2015
On 8/14/2015 1:30 PM, Walter Bright wrote:
> On 8/14/2015 5:51 AM, Andrei Alexandrescu wrote:
>> On 8/13/15 8:16 PM, Walter Bright wrote:
>>> On 8/13/2015 5:22 AM, CraigDillabaugh wrote:
>>>> No configuration file should be in a format that doesn't support
>>>> comments.
>>>
>>> [ "comment" : "and you thought it couldn't have comments!" ]
>
> Should be { }, not [ ]
>
>
>> There can't be two comments with the same key though. -- Andrei
>
> The Json spec doesn't say that - it doesn't specify any semantic meaning.
>

That is, the ECMA 404 spec. There seems to be more than one JSON spec.

www.ecma-international.org/.../files/.../ECMA-404.pdf
August 14, 2015
On Friday, 14 August 2015 at 17:40:01 UTC, Steven Schveighoffer wrote:
> On 8/14/15 1:30 PM, deadalnix wrote:
>> It doesn't matter what you think of JSON.
>>
>> JSON is widely used an needed in the standard lib. PERIOD.
>
> I think you are missing that this sub-discussion is about using json to replace dmd configuration file.
>
> -Steve

dub uses sdlang, why not dmd?
August 14, 2015
On 8/14/2015 5:40 AM, Jacob Carlborg wrote:
> On 2015-08-14 10:04, Walter Bright wrote:
>
>> Yes, but we (will) have a .json parser in Phobos.
>
> Time to add a YAML parser ;)

That's a good idea, but since dmd already emits json and requires incorporation of the json code, the fewer file formats it has to deal with, the better.

Config files will work fine with json format.

August 14, 2015
On 8/14/2015 6:30 AM, Andrei Alexandrescu wrote:
> On 8/14/15 9:10 AM, Steven Schveighoffer wrote:
>> Though, I would much rather see a better comment tag than "comment":.
>> json isn't ideal for this.
>
> You're right. Good convo:
> http://stackoverflow.com/questions/21832701/does-json-syntax-allow-duplicate-keys-in-an-object
> -- Andrei
>

When going for portability, it is not a good idea to emit duplicate keys because many json parsers fail on it. For our own json readers, such as reading a dmd.json file with our own parser, it should be fine.
August 15, 2015
On Friday, 14 August 2015 at 20:44:59 UTC, Walter Bright wrote:
> On 8/14/2015 5:40 AM, Jacob Carlborg wrote:
>> On 2015-08-14 10:04, Walter Bright wrote:
>>
>>> Yes, but we (will) have a .json parser in Phobos.
>>
>> Time to add a YAML parser ;)
>
> That's a good idea, but since dmd already emits json and requires incorporation of the json code, the fewer file formats it has to deal with, the better.
>
> Config files will work fine with json format.

Walter, and what I should to do for commenting stringin config for test purpose? How it's can be done with json?

I really think that dmd should use same format as dub