std.data.json formal review
Steven Schveighoffer via Digitalmars-d
digitalmars-d at puremagic.com
Fri Aug 14 07:09:28 PDT 2015
On 8/14/15 9:37 AM, "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?=
<ola.fosheim.grostad+dlang at gmail.com>" wrote:
> On Friday, 14 August 2015 at 13:30:44 UTC, Andrei Alexandrescu wrote:
>> On 8/14/15 9:10 AM, Steven Schveighoffer wrote:
>>> On 8/14/15 8: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!" ]
>>>
>>> This is invalid (though probably unintentionally). An array cannot have
>>> names for elements.
>>>
>>>> There can't be two comments with the same key though. -- Andrei
>>>
>>> Why not? I believe this is valid json:
>>>
>>> {
>>> "comment" : "this is the first value",
>>> "value1" : 42,
>>> "comment" : "this is the second value",
>>> "value2" : 101
>>> }
>>>
>>> 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
Yes, that's what I checked first :)
> No, he is wrong, and even if he was right, he would still be wrong. JSON
> objects are unordered so if you read then write you can get:
>
> {
> "comment" : "this is the second value",
> "value1" : 42,
> "value2" : 101
> }
Sure, but:
a) we aren't writing
b) comments are for the human reader, not for the program. Dmd should
ignore the comments, and it doesn't matter the order.
c) it's not important, I think we all agree a format that has specific
allowances for comments is better than json.
-Steve
More information about the Digitalmars-d
mailing list