Re: [Jsonpath] Index selector [-0] non-existent end of an array?

Greg Dennis <gregsdennis@yahoo.com> Wed, 06 March 2024 20:20 UTC

Return-Path: <gregsdennis@yahoo.com>
X-Original-To: jsonpath@ietfa.amsl.com
Delivered-To: jsonpath@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id B5EA1C14F5F9 for <jsonpath@ietfa.amsl.com>; Wed, 6 Mar 2024 12:20:41 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.105
X-Spam-Level:
X-Spam-Status: No, score=-2.105 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_BLOCKED=0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.com
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vPMIqcqRX-pg for <jsonpath@ietfa.amsl.com>; Wed, 6 Mar 2024 12:20:40 -0800 (PST)
Received: from sonic318-26.consmr.mail.bf2.yahoo.com (sonic318-26.consmr.mail.bf2.yahoo.com [74.6.135.81]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id B2C5FC14E513 for <jsonpath@ietf.org>; Wed, 6 Mar 2024 12:20:35 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1709756434; bh=BHrzYNlpteNYwj8ApohpOZeP63vNJszCD3JTyMBenpY=; h=Date:From:To:In-Reply-To:References:Subject:From:Subject:Reply-To; b=JNO70nLsLhkCHAsqpu+HS+zPw9mahOduvx2xOgqgm2NVk4aOup2nlXe17hlEUaqZNtJrZyX8xTzXvEoXDaonkzeGcDIiemGi8x2DsQSbfuJ6oKyfKTZ8Xay87BVvudO5xed7OZ0SbwxxHBzkHKoUR1wmZ1TTrA42CehSPkAyyhtC7gCRN2Zi7DbMYeu7J4avm8NUInIsSKqO4zVuRl3GMJt1g0mfF5Gff2elhXkLWkIfl/u2/HnxaiCSfOV88jNe1V6bL0WkY2JO0+ZBo1hxWDnNe7ug+uBQYaHCP0k117Jey3WOYw2Qg5YYVYPHDLEEFqY7ON5S/w/9tYz0eVbxrQ==
X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1709756434; bh=bQt0vHKXBEUpItMLcGM3Plch/TgFtVaK0f4mMiwm0h+=; h=X-Sonic-MF:Date:From:To:Subject:From:Subject; b=i0O86uL8/YACxQe8IJLzidwvgDr1a17FSv5goGYkxRuVyRcapvwZUbaXFvFnoC/IwGEuRBJibmfVxkUQHxQJuobZ2XVUZHD57reV808JnOdwcee/xzlKiuIXHMlg/rQ8nsYDMNgRVaf6P9ONBPCY0C/ser3GLosWTFUxVYHZWAoMOveDwT9wxwvwYySzBPRF3psZVcK4Id7yn6uAot6mVbVRLYOavGuBrS26u2xxu8x/WJGua+l5yjWHaRFuEokNgPmWt/qAcHqTPejsVY2l5EmhbN/u3l1oZ3YJFZqZxp8HecJGbydwfhvtdWMVGPcrklTNAFR12SIGiSsWj7WH4g==
X-YMail-OSG: 0OC.0QkVM1m42tWtVHwvMYuXYuNZWJ3s.xcZW2H6ip6O45gGTvRSiKdC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Nd8kOOmRL D1CAxPb3y_qX4Lvmfw_BWV17a54BoAfB50QXpAG7uD_zyz_XQ4Sdy.Q7kijdY_fK5p7U2Ns0a9EC 1O.kTv0l6OB_BHY.7n47RUofRYWHnYVaoWkOWoStwrv826Yg8o4uc0YFWpYwq437MPfpuU90T1vI DwYA-
X-Sonic-MF: <gregsdennis@yahoo.com>
X-Sonic-ID: e7ad44ec-00c0-4fd5-85f9-9bb6d4526315
Received: from sonic.gate.mail.ne1.yahoo.com by sonic318.consmr.mail.bf2.yahoo.com with HTTP; Wed, 6 Mar 2024 20:20:34 +0000
Date: Wed, 06 Mar 2024 20:19:53 +0000
From: Greg Dennis <gregsdennis@yahoo.com>
To: "jsonpath@ietf.org" <jsonpath@ietf.org>, Joel Bruner <joel@brunerd.com>
Message-ID: <1256872557.594787.1709756393481@mail.yahoo.com>
In-Reply-To: <E002AA3B-F3F6-4F6E-8DF6-6E727E237291@brunerd.com>
References: <E002AA3B-F3F6-4F6E-8DF6-6E727E237291@brunerd.com>
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="----=_Part_594786_1632147419.1709756393479"
X-Mailer: WebService/1.1.22129 YMailNorrin
Archived-At: <https://mailarchive.ietf.org/arch/msg/jsonpath/rYam8AL86lIWPO4wrS4QFbefbc8>
Subject: Re: [Jsonpath] Index selector [-0] non-existent end of an array?
X-BeenThere: jsonpath@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: Discussion of JSONPath syntax <jsonpath.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/jsonpath>, <mailto:jsonpath-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/jsonpath/>
List-Post: <mailto:jsonpath@ietf.org>
List-Help: <mailto:jsonpath-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/jsonpath>, <mailto:jsonpath-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 06 Mar 2024 20:20:41 -0000

 Thank you for your questions.  I'm sorry that you feel let down by our work.

JSON Point4er RFC6901 managed to define this very useful thing with a couple sentences in its 8 pages, yet in the 62 pages of the JSONPath spec somehow this is out of scope?

The purpose of JSON Path is to query JSON data.  The purpose of JSON Pointer is to indicate a single location (or potential location) within JSON data.  In general, a developer is expected to use the right tool for the job; if they need to specify a single location, they should use JSON Pointer.  That's what it was created for. 

A specification (any specification) cannot be responsible for people operating outside of its scope.  As such, it cannot be expected to support every (or any) scenario that arises from such use.
As another example, I am also an author on JSON Schema.  The purpose of JSON Schema is validation and annotation of JSON data.  Moreover its model is a collection of constraints, which is inherently incompatible with data modelling.  However that hasn't stopped people from using it for form and code generation or a multitude of other uses.  The existence of those other uses doesn't change the specification's purpose, though, and it doesn't push us to expand the scope.  The spec is still only validation and annotation.  Instead, there are separate-but-related efforts to standardize how to use JSON Schema for these other purposes.
Additionally, JSON Schema has an org behind it now.  JSON Path had merely a short-lived IETF working group.  Such a working group is (by mandate) going to be very targeted in its focus, meaning the spec is going to be written in such a way as to achieve its goal, and nothing more.
There are some murmurs about a JSON Path v2, for which we may be open to expanding the scope, but the goal for the first go-around was to standardize.  Feel free to open an issue with your proposal, and it will be discussed.
Until then, please feel free to use JMESPath or another similar syntax which gives you the functionality you're looking for.
Greg
    On Tuesday, March 5, 2024 at 08:56:40 PM GMT+13, Joel Bruner <joel@brunerd.com> wrote:  
 
 The other day someone was asking me how to insert a value at the end an array (using my jpt tool)… so I said something like: "Well in JSON Pointer it's "/-" and for JSONPath I borrowed the convention and use $[-]"… to which they replied "the spec seems to indicate it should be [-0]" – which had me quite puzzled since when brought this up in 2022 it was deemed out of scope by some and nonsensical to others.
While in "2.3.3.2. Semantics" it is somewhat implied since the $[-1] is the end of an array and it does follow that $[-0] is after that, the ABNF for "2.3.3.2. Semantics" seems to explicitly exclude -0 only allowing "-" with digits 1-9
>  An index selector <index> matches at most one array element value.>  index-selector      = int                        ; decimal integer>  int                 = "0" />                         (["-"] DIGIT1 *DIGIT)      ; - optional>  DIGIT1              = %x31-39                    ; 1-9 non-zero digit
Only later in "Figure 2" of "Appendix A" and in "2.3.5.1. Syntax" does "-0" make an appearance since this is a "signed zero" that Javascript allows but JSON can't roundtrip > number              = (int / "-0") [ frac ] [ exp ] ; decimal number
So it seems there really is no syntax for the non-existent end of an array in JSONPath – and for a while I was kind of excited there had been a change of heart.
When I look back I see Greg Dennis had this well meaning thing to say:

I think this is the crucial point: JSON Path is intended as only a query language.  It's not intended to specify a location for days to be set/inserted.
Yet, two years later and it seems folks still haven't "gotten the memo" and are using JSONPath syntax not just for querying but for specifying locations to insert data. Why shouldn't they?  It's like approaching this by saying "People are the problem, the spec is just fine". JSON Point4er RFC6901 managed to define this very useful thing with a couple sentences in its 8 pages, yet in the 62 pages of the JSONPath spec somehow this is out of scope? It's such a simple thing to define, why not? I don't think it's a slippery slope to define either [-] or [-0] as the non-existent end of an array… two years ago I should have pushed back harder. The things not defined now will just mutate down the road.
Thanks,Joel Bruner-- 
JSONpath mailing list
JSONpath@ietf.org
https://www.ietf.org/mailman/listinfo/jsonpath