[getdns-api] Getting from dicts by subscript operator
Willem Toorop
willem at nlnetlabs.nl
Mon Oct 5 13:15:11 UTC 2015
Op 05-10-15 om 15:07 schreef Willem Toorop:
> Op 23-09-15 om 21:37 schreef Joe Hildebrand (jhildebr):
>> On 9/23/15, 7:37 AM, "Shane Kerr" <shane at time-travellers.org> wrote:
>>> I think that the last one is "correct" JSON Pointer syntax if I
>>> understand the RFC, but I confess that the one above it looks easier to
>>> read to me. :)
>>
>> The last one. I know it's slightly strange to a C programmer, but to a JavaScript programmer, it's not *too* strange, where a['foo'] === a.foo. The advantage here is that in a getdns wrapper that is treating the results as JSON, you could use an existing json-pointer implementation. Also, you don't have to worry about specifying the BNF for the query syntax, thinking about the edge cases, and worrying about the security consequences quite as much.
>
> Good point. Since it has to become part of the spec, it is easier to
> reference an existing syntax (especially since it is standardized) than
> to describe a new one. I have come up with the following wording, to
> append to the first subsection of section 2. (so just before 2.1. starts)
>
> When the name parameter to the getdns_dict_get_ functions, starts with
> a '/' (%x2F) character, it is interpreted as a JSON Pointer as described
> in RFC6901, and will then be used to dereference the nested data
> structures to get to the requested data type.
>
>
> And at the end of section 2.1.
>
>
> When the name parameter to the getdns_dict_set_ functions, starts with
> a '/' (%x2F) character, it is interpreted as a JSON Pointer as described
> in RFC6901, and will then be used to dereference the nested data
> structures to get to the requested data type.
Sorry, I copy pasted but forgot to alter. So I propose this paragraph
the the spot:
When the name parameter to the getdns_dict_set_ functions, starts with
a '/' (%x2F) character, it is interpreted as a JSON Pointer as described
in RFC6901, and will then be used to dereference the nested data
structures to set the given value at the specified name or list index.
>
>
> Comments or better wordings are welcome.
>
> I think the examples in the spec could also benefit from using JSON
> Pointer syntax. They are likely to become much shorter and therefor
> more readable and easier to digest. Take for example this alternative
> for the example in section 6.4 (I started with the shortest):
>
> https://github.com/getdnsapi/getdns/blob/features/json-pointers/spec/example/synchronous-json-pointer.c
>
> What do you think?
>
> -- Willem
> _______________________________________________
> spec mailing list
> spec at getdnsapi.net
>
More information about the spec
mailing list