std.data.json formal review
Etienne Cimon via Digitalmars-d
digitalmars-d at puremagic.com
Tue Jul 28 18:41:55 PDT 2015
On Tuesday, 28 July 2015 at 18:45:51 UTC, Sönke Ludwig wrote:
> Am 28.07.2015 um 17:19 schrieb Etienne Cimon:
>> On Tuesday, 28 July 2015 at 14:07:19 UTC, Atila Neves wrote:
>>> Start of the two week process, folks.
>>>
>>> Code: https://github.com/s-ludwig/std_data_json
>>> Docs: http://s-ludwig.github.io/std_data_json/
>>>
>>> Atila
>>
>> This is cool:
>> https://github.com/s-ludwig/std_data_json/blob/aac6d846d596750623fd5c546343f4f9d19447fa/source/stdx/data/json/value.d#L183
>>
>>
>> I was getting tired of programmatically checking for null,
>> then checking
>> for object type, before moving along in the object and doing
>> the same
>> recursively. Not quite as intuitive as the optional chaining
>> ?. operator
>> in swift but it gets pretty close
>> https://blog.sabintsev.com/optionals-in-swift-c94fd231e7a4#5622
>
> An idea might be to support something like this:
>
> json_value.opt.foo.bar[2].baz
> or
> opt(json_value).foo.bar[2].baz
>
> opt (name is debatable) would return a wrapper struct around
> the JSONValue that supports opDispatch/opIndex and propagates a
> missing field to the top gracefully. It could also keep track
> of the complete path to give a nice error message when a
> non-existent value is dereferenced.
I like it quite well. No, actually, a lot. Thinking about it some
more... this could end up being the most convenient feature ever
known to mankind and would likely push it towards a new age of
grand discoveries, infinite fusion power and space colonization.
Lets do it
More information about the Digitalmars-d
mailing list