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
JMESPath – A query language for JSON
41–50 of 131 posts
Re: JMESPath – A query language for JSON
#42The 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…
Re: JMESPath – A query language for JSON
#43The 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
Re: JMESPath – A query language for JSON
#44sort(@)
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
#45The 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
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
#46the 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…
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
#47Earlier 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.
Re: JMESPath – A query language for JSON
#48Earlier 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?
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
#49Does 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…
Re: JMESPath – A query language for JSON
#50the 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…
X | Y | Z
The @ is the result from the prior transform.
I would've preferred _ from scala, but meh.