[Jsonpath] Remarks on the JSONPath ABNF grammar in draft-goessner-dispatch-jsonpath-00.html

Daniel P <danielaparker@gmail.com> Thu, 12 November 2020 17:37 UTC

Return-Path: <danielaparker@gmail.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 9D21E3A144B for <jsonpath@ietfa.amsl.com>; Thu, 12 Nov 2020 09:37:25 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.098
X-Spam-Level:
X-Spam-Status: No, score=-2.098 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4ONmEH-xVj-p for <jsonpath@ietfa.amsl.com>; Thu, 12 Nov 2020 09:37:24 -0800 (PST)
Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 256A33A1448 for <jsonpath@ietf.org>; Thu, 12 Nov 2020 09:37:24 -0800 (PST)
Received: by mail-wr1-x42d.google.com with SMTP id c17so6859429wrc.11 for <jsonpath@ietf.org>; Thu, 12 Nov 2020 09:37:24 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=JFdlKngq5uEjTteFnPYZvB+HUa2TENOq/Exfw948/pk=; b=Gkj95XMM6QvWUS3EZMDmOZb+jpOoVRwRi26nieVd3m9jMNZdg870Wwj4XlaR38nPc1 YleOj9rmFOJ536+e8BxXx8ueUgcGHJ1ShU5keMYVL+/D+xO8HWy+LD338sfIDqGTtpM7 sYzzxlCSjYZqgRmi8S01esYtW54+ggXnGv6qCoWmubhYJkajMKpdnRy4EPgN0Q+qIYZ5 9vI0iOGbZH+w+5Kq2pvK9nl9IoIJ+BPCPlVtkqz2MQuT14/l8Ubz7KTEmccmbqiP0Fhu aLxx8dTq6vfgVv+AJIjfMroH1Uxw/5HtCmOH0dpTBXF3PhumL7Y+gvOiHVVUOHvSCaII mrfw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=JFdlKngq5uEjTteFnPYZvB+HUa2TENOq/Exfw948/pk=; b=Q3yRDCR91RM9gaRJMJ2uFlFSw0fSD4tc9GvFk9wPxP6r9k25X93UBwh78gXcLE5fZx oL9YvfJGR8PZUxVfG0/je/EX6zxkUJviFZKmj1CG439LmFfTkkLib9rJFdxnDRSE1+w8 6w/1bz2Fx1WJ4xNMeEqrMLQQdAxKSkdIHiJC7rudOlffdjbKm4zVRy0yu7p3AM1U95/o TqtDmXtKqUqRCOMBZQhnIeGcv1QZePLSSjOIiIwpwlFiXJEOArWA2Si5Up5+A0aoBP3X w+eDFRMD8lYFmpU2tYfcuBbznru0LhyDNKDDr1FlASUt9lW6bpjzvFEApVunaF3yLU/Y iRbg==
X-Gm-Message-State: AOAM530a8viVVneNhyc9IEpzE/UxMha2+8nx3y0N1roSfx/O23hGXjzc K1Gly/WSXCl0O0ZkoyPfchJwpvPhGZuW2dq4HcgczacFxWLTPA==
X-Google-Smtp-Source: ABdhPJyiB2ToacD6PclO48YATET92XR5yAqPKBu+uVfjqp9715ppeeEG30Rbi3voKZeM9DDX0jfcU/zO56DbMMY5NNg=
X-Received: by 2002:adf:fb0f:: with SMTP id c15mr719151wrr.86.1605202642003; Thu, 12 Nov 2020 09:37:22 -0800 (PST)
MIME-Version: 1.0
References: <mailman.76.1605124809.24440.jsonpath@ietf.org>
In-Reply-To: <mailman.76.1605124809.24440.jsonpath@ietf.org>
From: Daniel P <danielaparker@gmail.com>
Date: Thu, 12 Nov 2020 12:37:09 -0500
Message-ID: <CA+mwktJNRJr63_Lx1vNA2FBX4gYJWP3CXvcbhuXS-Exe_h9jwg@mail.gmail.com>
To: jsonpath@ietf.org
Content-Type: text/plain; charset="UTF-8"
Archived-At: <https://mailarchive.ietf.org/arch/msg/jsonpath/0UtRfkC9fMqnnEUokCoF9OTCwR4>
Subject: [Jsonpath] Remarks on the JSONPath ABNF grammar in draft-goessner-dispatch-jsonpath-00.html
X-BeenThere: jsonpath@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: A summary description of the list to be included in the table on this page <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: Thu, 12 Nov 2020 17:37:26 -0000

In https://www.ietf.org/archive/id/draft-goessner-dispatch-jsonpath-00.html,
in Section 3, there is a suggested JSONPath ABNF grammar.

(1) A slice expression within square brackets  is expressed as

value-expression *2(":" value-expression)

value-expression = *DIGIT / name
                 / script-expression / filter-expression

Note that a slice expression in Goessner is defined with reference to
the (long since abandoned) ECMASCRIPT 4. The original link is lost,
but there is some discussion here,
https://web.archive.org/web/20070125020659/developer.mozilla.org/es4/proposals/slice_syntax.html.

I've never seen an attempted formalization of JSONPath (or JMESPath,
for that matter) that defines a slice expression allowing general
expressions, nor do I think there is any prior experience with that in
any existing implementations. Also note that negative numbers are
allowed in slice expressions as per ECMASCRIPT 4. The usual definition
is

slice-expression  = [number] ":" [number] [ ":" [number] ]
number            = ["-"]1*digit

(2) In

step = ".." name ; nested descendants
     / "." name ; child (dot notation)

name = "'" text "'"
     / "*" ; wildcard

a name is defined as a single quoted string or a wildcard.

But note that JSONPath also supports unquoted strings. So perhaps

step = ".." name-or-wildcard ; nested descendants
     / "." name-or-wildcard ; child (dot notation)

name-or-wildcard = unquoted-name / single-quoted-name / wildcard

single-quoted-name = ; must escape single quotes in character sequence
unquoted-name = ; must start with an alphabetic character

Also note that a number of implementations (but not Goessner) support
double quoted names as an extension.

(3) Many JSONPath implementations support functions. For example the
popular and influential jayway implementation,
https://github.com/json-path/JsonPath, supports a somewhat limited
idea of functions that can be invoked at the tail end of a path - min,
max, avg, stddev, length, sum. We also see this adopted in Oracle's
version of JSONPath,
https://docs.oracle.com/cd/E60058_01/PDF/8.0.8.x/8.0.8.0.0/PMF_HTML/JsonPath_Expressions.htm.
There are other implementations that take a more general approach to
functions, more along the lines of XPath.

Is it within the scope of the working group to discuss functions?
There are some implications for the grammar.

Daniel