
Jsonpath – a query language for JSON in Postgres [pdf] - craigkerstiens
http://www.sai.msu.su/~megera/postgres/talks/jsonpath-pgday.it-2019.pdf
======
cle
Here's the real JSONPath:

[https://goessner.net/articles/JsonPath/](https://goessner.net/articles/JsonPath/)

This submission is for PostgreSQL's "JSON Path", which is very similar to the
original JSONPath. I'm surprised, and disappointed, that there is no mention
of the original JSONPath, which this is obviously inspired by.

~~~
aasasd
So, what I'm seeing is that I currently have JQ, and if I get around to
dealing with Postgre, I might also have SQL's JSONPath. And then if I get
tired of juggling objects/dicts/arrays in my programs, I can also pick a not-
quite-the-same JSONPath as a lib.

(Though the latter is unlikely, since Lisp and FP have taught me that a bunch
of functions feeding into each other will do exactly the same thing quite
fine.)

~~~
Terretta
Don’t forget JMESPath, as built into AWS CLI:

[http://jmespath.org/](http://jmespath.org/)

With language libraries or as jp CLI:

[http://jmespath.org/libraries.html](http://jmespath.org/libraries.html)

Example AWS CLI tricks:

[https://gist.github.com/magnetikonline/6a382a4c4412bbb68e33e...](https://gist.github.com/magnetikonline/6a382a4c4412bbb68e33e137b9a74168)

[https://opensourceconnections.com/blog/2015/07/27/advanced-a...](https://opensourceconnections.com/blog/2015/07/27/advanced-
aws-cli-jmespath-query/)

~~~
kapilvt
Jmespath is also built in to the azure cli

------
donpdonp
json processing languages peaked with jq's language.

[https://stedolan.github.io/jq/manual/](https://stedolan.github.io/jq/manual/)

~~~
asah
Is there a detailed comparison between JSONpath and jq? I'm esp interested in
examples where jq is more powerful, e.g. jq one liner but JSONpath can't.

------
d33
Does anybody else feel that the syntax is terrible and SQL is not a good fit
for this? I, for one, would appreciate if the paths were accessible via a
change to the SQL syntax as opposed to a magic operator or - even worse - a
new function. Not to mention that the more complex the queries become, the
more pain one can expect the query planner to be... personally, I'd prefer to
make my own query plans instead, laying down the algorithms according to the
best of my knowledge of the dataset.

It's not like optimizing in C, where the compiler looks at the AST and can
actually discover something you wouldn't think of. My experience with
PostgreSQL's query planner is that it requires so much fine-tuning it's near
unusable and super quirky.

That isn't to say that I don't like PostgreSQL and its JSON capabilities -
it's just that the more I use it, the more I wish there was something between
it and current NoSQL databases...

------
hyuuu
another alternative is jsonata, backed by IBM: [https://github.com/jsonata-
js/jsonata](https://github.com/jsonata-js/jsonata)

------
picod
my 110 loc implementation [https://github.com/ldarren/pico-
common/blob/master/src/plugi...](https://github.com/ldarren/pico-
common/blob/master/src/plugins/json.js)

you can try it here [http://json.jasaws.com/](http://json.jasaws.com/)

------
Kip9000
Looks like an inferior subset of XPath which is much cleaner and powerful

~~~
klodolph
Isn't XPath for XML? How would you use it with JSON?

~~~
thechao
Xpath’s relationship to XML is like CSS to HTML: its natural domain—and most
common use—is XML. However, it is a general path selection/query mechanism
with a UNIX-file-path-like syntax.

~~~
theamk
There are large parts of XPath which are XML specific, like attributes or
namespaces or node names (JSON’s arrays of arrays have neither). I am sure
with enough effort one could use Xpath for generic JSON queries, but this will
require non-obvious redesign of the language.

------
stonogo
Interesting to see the old Soviet Union TLD is still in use.

There's a pretty nice jsonpath implementation that was recently produced at
[https://github.com/pacifica/python-
jsonpath2](https://github.com/pacifica/python-jsonpath2)

I haven't switched to it yet, but I'm keeping an eye on it, to see how long
it's supported

~~~
aasasd
> _Interesting to see the old Soviet Union TLD is still in use._

Weird to see a proper institution on that domain. The .su itself is quite
alive and available for registration. It's mostly used as a “quirky knockoff
tld,” in the spirit of .io and such.

