Live data from Hacker News

JMESPath – A query language for JSON

jmespath.org

41–50 of 131 posts

Re: JMESPath – A query language for JSON

#41
post #18

The reinvention of XML in JSON is almost complete - JMESPath vs XPath, JSON Schema vs XML Schema etc. If you need semi structured data to that level, consider using XML instead - you can validate it, there's plenty of tools, it's very stable and mature etc

But can you store XML in a database that is Web Scale?? /s

SQLite will happily store whatever you throw at it and scales perfectly to my Web Site ;)

Re: JMESPath – A query language for JSON

#42

The example on the front page seems equivalent to (and only marginally less verbose than): locations .filter(l => l.state === 'WA') .map(l => l.name) .sort() .join(', ')

The benefit of a query language is that it can be described declaratively (i.e. in a non-executable text file, perhaps within JSON itself), and then programs written in any language can execute its query logic using a standard interpreter written in that specific programming language. So you get reusability of queries across the stack, in all languages that implement a parser against the spec. Your example only provi…

[deleted]

Re: JMESPath – A query language for JSON

#43

The reinvention of XML in JSON is almost complete - JMESPath vs XPath, JSON Schema vs XML Schema etc. If you need semi structured data to that level, consider using XML instead - you can validate it, there's plenty of tools, it's very stable and mature etc

Hm. One reason why I prefer Json to XML (and I actually like XML) is, that JSON is simpler. The fact that XML has schema definitions out of the box, and that these schema definitions can reference other definitions would lead to more complex parsers that can contain more bugs and vulnerabilities.

Re: JMESPath – A query language for JSON

#44
the second I looked at the example on the homepage and saw this:

sort(@)

I'm like nope! What is this "@" symbol? Why can't that be "name"? I'm already passing judgment that this library will be a nightmare to use which isn't good.

Now I know I can read the docs and eventually what I can pass the sort expression and what it all means, however, this is an issue I come across more and more with new libraries in programming... show simple examples, not "smart" or complicated ones. I shouldn't have to read through docs to try to decipher an introductory example. There is a reason every programming language starts with "Hello World".

Re: JMESPath – A query language for JSON

#45

The reinvention of XML in JSON is almost complete - JMESPath vs XPath, JSON Schema vs XML Schema etc. If you need semi structured data to that level, consider using XML instead - you can validate it, there's plenty of tools, it's very stable and mature etc

Last time I checked, XML was uncertain which validation should I use. DTD, Schema, other solutions. Each has syntax/structure and 1st page explanation so cryptic, that I don’t even understand where do I begin.

I don’t like js/json at all, but for json (and without much js knowledge) I can roll out simple validation in less time than is needed to understand these schema formats. If my structure is dynamic, omg it will be hard to explain it to declarative validator. If it contains value-level type logic (graphs, references), I bet second phase of validation by hand is inevitable anyway.

A second thing, full-blown xml is alien to any structures of simple languages and cannot be serialized like jsonlib.encode(foo). You create nodes, set attributes, build trees, all that mess. It feels like using a 17th century official mail ceremony to send “)))” to your buddy.

Re: JMESPath – A query language for JSON

#46

the second I looked at the example on the homepage and saw this: sort(@) I'm like nope! What is this "@" symbol? Why can't that be "name"? I'm already passing judgment that this library will be a nightmare to use which isn't good. Now I know I can read the docs and eventually what I can pass the sort expression and what it all means, however, this is an issue I come across more and more with new libraries in programm…

This is not that new. And it happens to be the JSON query language built in to the AWS CLI tools.

For last 3 - 4 years I see lots of AWS CLI examples piping through jq. That’s an extra dependency that’s not necessary when this is built in.

Here’s the author’s idea of intro materials (posted Jan 2015):

http://jamesls.com/how-to-easily-explore-jmespath-on-the-com...

I’ve found him very responsive on bugs and (provably useful) feature ideas.

Re: JMESPath – A query language for JSON

#47
post #23

Earlier quoted context omitted.

Isn't that what we want? I would think that solving the same problems for a less verbose format is a good thing. And looking at the examples and the library support ( http://jmespath.org/libraries.html ) I would say this solves a real problem. I can already think of several use cases for my own system. The fact that a solution is treading familiar ground does not invalidate its utility.

It's not very much less verbose, really. You still need a key and a value. The only thing you lose, really, is the end tag. For a complex text document in say TEI or Docbook, I don't see how this is much of an advantage.

It's less complex since there aren't attributes. Of course, if you like attributes, then that's a downside.

Re: JMESPath – A query language for JSON

#48

Earlier quoted context omitted.

The "reinvention" is not complete and will never be necessary. The difference is that XPath is necessary to query XML because it's a botched horribly overcomplicated, designed-by-committee markup language. Except for tools like jq no such language is actually required for JSON because it maps on to language structures that always exist. Neither JSON schema or XML schema are particularly popular - and for good reason.…

That ability to use outside canonical sources is really interesting. Are there some existing examples of schema languages with that feature?

The point I was making was that you shouldn't use a "special" language for validation at all - you should just use a library in a regular language to do it.

Anyway, code:

yaml_text:

   John: Yemen
   James: South Sudan
python code:

   from strictyaml import load, MapPattern, Str, Enum
   import pycountry

   result = load(
       yaml_text,
       MapPattern(
           Str(),
           Enum([country.name for country in pycountry.countries]),
       )
   )
full disclosure: I wrote the validation library ^^

Re: JMESPath – A query language for JSON

#49
post #39

Does this have any mathematical foundation like the relational algebra for SQL? Or more generally, does a mathematical framework exist to treat this or similar constructs and that goes beyond what relational algebra provides and that, for example, also handles aggregate functions? The reason I am asking is that I am currently trying to build a tool to analyze a kind of time series data, think log file entries, in ord…

load the data into a database (sqlite is very good). use the database. delete the database.

Re: JMESPath – A query language for JSON

#50

the second I looked at the example on the homepage and saw this: sort(@) I'm like nope! What is this "@" symbol? Why can't that be "name"? I'm already passing judgment that this library will be a nightmare to use which isn't good. Now I know I can read the docs and eventually what I can pass the sort expression and what it all means, however, this is an issue I come across more and more with new libraries in programm…

Each step is a transformation

X | Y | Z

The @ is the result from the prior transform.

I would've preferred _ from scala, but meh.

Post reply on HN