Subject: Re: [apps-discuss] Ultimate and penultimate array references with json-pointers?

From: Mark Nottingham <[email-masked]>
Date: Mon, 11 Mar 2013 09:44:15 -0400

Hi Steffen,

JSON Pointer is already in the RFC Editor queue, so it's too late to make this sort of change.

Cheers,

On 10/03/2013, at 4:52 AM, Steffen Yount <[email-masked]> wrote:

> Hi Paul, Kris, & Mark,
> 
> I'm working on a json-hyper-schema integration that relies on json-pointers where I want a single json-pointer value that can reference the last or possibly second to last item in a variable length JSON array.
> 
> Unfortunately, the json-pointer definition as-is has no built-in mechanism to support this kind of tail-offset array reference.
> 
> Would it be possible to modify the "draft-ietf-appsawg-json-pointer" I-D to support negative values as array-indexes where a value (-x) would be semantically equivalent to the positive index value (array.length - x)?
> 
> Example references for the last and second to last elements could look like:
>    "/foo/-1"     "baz"
>    "/foo/-2"     "bar"
>    #/foo/-1      "baz"
>    #/foo/-2      "bar"
> 
> 
> The new wording for the JSON Array evaluation section could look like:
> 
> 
>   o  If the currently referenced value is a JSON array, the reference
>      token MUST contain either:
> 
>      *  characters representing a positive base-10 integer value (see 
>         ABNF below; note that leading zeros are not allowed), making 
>         the new referenced value the array element identified by the 
>         zero-based index value in the token, or
> 
>      *  characters representing a negative base-10 integer value, 
>         making the new referenced value the array element identified 
>         by the zero-based index value found by adding the negative
>         token value to the count of elements in the array, or
> 
>      *  exactly the single character "-", making the new referenced
>         value the (non-existent) member after the last array element.
> 
>   The ABNF syntax for array indices is:
> 
>   array-index = %x30 / ( *(%x2D) %x31-39 *(%x30-39) ) / %x2D
>                 ; "0", a signed integer without a leading "0", or "-"
> 
> 
> 
> Yes? No? Your thoughts?
> 
> Thanks for your consideration,
> -Steffen

--
Mark Nottingham   http://www.mnot.net/