Subject: [Jsonpath] JSONpath corner case

From: Tim Bray <[email-masked]>
Date: Wed, 23 Sep 2020 21:35:07 -0700

Just because this came across my radar this evening, here's the kind of
interesting corner case to amuse people who want to work on this.

Consider this perfectly legal JSON object

{
 "ab": 0,  "'a.b": 1,  "a-b": 2,
 "a": {  "b": 3 }
}

So $.ab is 0, $.a.b is 3, $['a.b'] is 1, $['a-b'] is 2.  You'd like to say
$.a-b but lots of libraries will refuse it because "a-b" is not a legal
JavaScript "name" construct, that's why you have to say $['a-b'].

But suppose your library would accept $.a-b.  Then $.a-b and $['a-b'] would
be synonyms, but $.a.b and $['a.b'] wouldn't.

Fun!

---

From: Glyn Normington <[email-masked]>
Date: Thu, 24 Sep 2020 06:06:53 +0000

Hi Tim

Thanks for that. Indeed there’s much fun to be had. ;-)

Have you come across the JSONPath comparison project ([1]) which compares some 39 implementations and identifies where there is a consensus? It covers at least one of those corner cases ([2]).

As Barry pointed out yesterday, we don’t want follow the consensus this will cause us to descend into “mush". But the comparison project at least helps highlight various options.

Regards,
Glyn

[1] https://cburgmer.github.io/json-path-comparison/

[2] https://cburgmer.github.io/json-path-comparison/results/bracket_notation_with_dot.html

On 24 Sep 2020, at 05:35, Tim Bray <[email-masked]<mailto:[email-masked]>> wrote:

Just because this came across my radar this evening, here's the kind of interesting corner case to amuse people who want to work on this.

{

So $.ab is 0, $.a.b is 3, $['a.b'] is 1, $['a-b'] is 2.  You'd like to say $.a-b but lots of libraries will refuse it because "a-b" is not a legal JavaScript "name" construct, that's why you have to say $['a-b'].

But suppose your library would accept $.a-b.  Then $.a-b and $['a-b'] would be synonyms, but $.a.b and $['a.b'] wouldn't.

Fun!

--
Jsonpath mailing list
[email-masked]<mailto:[email-masked]>
https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ietf.org%2Fmailman%2Flistinfo%2Fjsonpath&amp;data=02%7C01%7Cnormingtong%40vmware.com%7Cc6eb4ef9e13845556acb08d860434196%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C1%7C637365189305839699&amp;sdata=5vJ21EzknX2%2BbTBupnUu0ugrZfS%2Bhdc1SmtSE4au5TI%3D&amp;reserved=0