I disagree. Adding a capability for other indices down the road is NOT
compatible for existing uses, so adding it will cause confusion ("are you using
the old JSON Pointer or the new one?") and interop problems.
IIRC the discussion in the WG went much along these lines, and led to us
explicitly choosing a single character, rather than a misleading "-1"
construct. I'd be more comfortable with changing the character to something
even further away, rather than making this construct even more confusing.
The other way we could go would be to do full negative indexing; we don't have
any use cases for that, and it increases complexity a bit, but at least it
would be unsurprising.
On 18/12/2012, at 6:54 AM, Barry Leiba <barryleiba(_at_)computer(_dot_)org>
wrote:
This was discussed in the Working Group, but it wasn't felt that the added
complexity was worth it; there's a strong feeling that this spec should be
as
simple as possible.
Might I suggest, however, using -1 instead of "-" to refer to the last item
in an
array, as this provides two benefits:
1) Allows for adding the complexity down the road in a compatible way, should
there be need
2) Uniformity; i.e. always using integer values for referring to array
elements.
I have to say that this suggestion sounds very compelling to me, for
both reasons. I know there's a bunch of running code out there, but
this (and perhaps teasing apart the "add" and "insert" concepts into
separate verbs) seems worth the bother.
Barry, as participant
--
Mark Nottingham http://www.mnot.net/