August 14, 2015 Re: std.data.json formal review | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On 15/08/2015 12:40 a.m., 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 ;)
Heyyy Sonke ;)
|
August 14, 2015 Re: std.data.json formal review | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Friday, 14 August 2015 at 12:40:32 UTC, 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 ;) I think kiith-sa has started on that: https://github.com/kiith-sa/D-YAML |
August 14, 2015 Re: std.data.json formal review | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | 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. -Steve |
August 14, 2015 Re: std.data.json formal review | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Friday, 14 August 2015 at 13:10:53 UTC, 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: http://tools.ietf.org/html/rfc7159 «The names within an object SHOULD be unique.» «An object whose names are all unique is interoperable in the sense that all software implementations receiving that object will agree on the name-value mappings. When the names within an object are not unique, the behavior of software that receives such an object is unpredictable. Many implementations report the last name/value pair only. Other implementations report an error or fail to parse the object, and some implementations report all of the name/value pairs, including duplicates. JSON parsing libraries have been observed to differ as to whether or not they make the ordering of object members visible to calling software. Implementations whose behavior does not depend on member ordering will be interoperable in the sense that they will not be affected by these differences.» |
August 14, 2015 Re: std.data.json formal review | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | 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 -- Andrei |
August 14, 2015 Re: std.data.json formal review | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | 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 -- Andrei
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
}
|
August 14, 2015 Re: std.data.json formal review | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On 14-Aug-2015 11:04, Walter Bright wrote: > On 8/13/2015 11:54 PM, Dmitry Olshansky wrote: >> On 14-Aug-2015 03:48, Walter Bright wrote: >>> On 8/13/2015 5:18 PM, Adam D. Ruppe wrote: >>>> On Thursday, 13 August 2015 at 03:44:14 UTC, Walter Bright wrote: >>>>> Hah, I'd like to replace dmd.conf with a .json file. >>>> >>>> There's an awful lot of people out there replacing json with more >>>> ini-like >>>> files.... >>> >>> We've currently invented our own, rather stupid and limited, format. >>> There's no point to it over .json. >> >> YAML is (plus/minus braces) the same but supports comments and is >> increasingly >> popular for hierarchical configuration files. > > Yes, but we (will) have a .json parser in Phobos. > We actually have YAML parser in DUB repository plus so that can be copied over to the compiler source interim. And doesn't have to be particularly fast it just have to work resonably well. -- Dmitry Olshansky |
August 14, 2015 Re: std.data.json formal review | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ola Fosheim Grøstad | On 8/14/15 9:37 AM, "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= <ola.fosheim.grostad+dlang@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 |
August 14, 2015 Re: std.data.json formal review | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Friday, 14 August 2015 at 14:09:25 UTC, Steven Schveighoffer wrote:
> 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.
One should have a config file format for which there are standard libraries that preserves structure and comments. It is quite common to have tools that read and write config files.
|
August 14, 2015 Re: std.data.json formal review | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ola Fosheim Grøstad | On 8/14/15 10:44 AM, "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= <ola.fosheim.grostad+dlang@gmail.com>" wrote: > On Friday, 14 August 2015 at 14:09:25 UTC, Steven Schveighoffer wrote: >> 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. > > One should have a config file format for which there are standard > libraries that preserves structure and comments. It is quite common to > have tools that read and write config files. And that would be possible here. JSON file format says nothing about how the data is stored in your library. But again, not important. -Steve |
Copyright © 1999-2021 by the D Language Foundation