Live data from Hacker News

JMESPath – A query language for JSON

jmespath.org

21–30 of 131 posts

Re: JMESPath – A query language for JSON

#21
post #4

May also be interested in the `jq` CLI, which on first glance appears to use a similar but not identical query language. https://stedolan.github.io/jq/

seconded. the jq language is surprisingly powerful and at first glance at jmespath, the syntax is similar.

Re: JMESPath – A query language for JSON

#22
post #19

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

Is that a bad thing? For cases where the document is at least partially written by hand it makes sense to replace XML with something more friendly, such as JSON or YAML.

Wasn't the basic idea of JSON to be small and unstructured to be sent between applications? Shoehorning everything into JSON that is already solved by XML seems illogical, as GP already said. It reeks of NIH.

People shouldn't use JSON for anything hand-written. YAML or even the older INI format are way better suited for configuration files for one reason alone: they allow comments.

Re: JMESPath – A query language for JSON

#23

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

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.

Re: JMESPath – A query language for JSON

#25
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

Yes. It's one of the many abilities a database like PostgreSQL has.

The "Web scale" is what MongoDB tried to sell (unfortunately, successfully), and it's not even close to being web scale.

Re: JMESPath – A query language for JSON

#28

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

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. Let's say you want to create a schema that limits field "country" to be limited to ISO 3166-1 country codes - either you:

* Keep that schema file updated by hand every time something like Sudan breaking in two happens (no).

* Write a program that generates the schema (seriously... no)

* Do schema validation in code where it belongs - pulling in relevant validation data from canonical sources, rather than some markup language invented by people who didn't have the imagination to consider a really common use case.

Re: JMESPath – A query language for JSON

#29
post #4

May also be interested in the `jq` CLI, which on first glance appears to use a similar but not identical query language. https://stedolan.github.io/jq/

seconded. the jq language is surprisingly powerful and at first glance at jmespath, the syntax is similar.

I think the equivalent jq query would be something like:

    [.locations[] | select(.state == "WA").name] | sort | join(", ") | { WashingtonCities: . }
Post reply on HN