Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why people use JMESPath instead of JQ? [closed]

Tags:

I need to work with some systems that use JMESPath to search JSON. But I found that it is missing a lot of important features. Let's say, it is very hard to search string with pattern (like this). It does not support regular expression. It does not support case insensitive search. The proposal to add split function has been frozen since 2017 (like this and this). These features are all available to jq. So I want to know why systems like AWS S3 CLI, and Ansible use JMESPath instead of jq to query JSON?

like image 755
HKTonyLee Avatar asked Jun 18 '21 18:06

HKTonyLee


1 Answers

It's not so much about the difference between JMESPath and jq as the different ways they are used.

Suppose you are querying a remote resource, the result is going to number in the millions of records, but you only care about a specific, much smaller subset of the records. You have two choices:

  1. Have every record transmitted to you over the network, then pick out the ones you want locally
  2. Send your filter to the remote resource, and have it do the filtering, only sending you the response.

jq is typically used for the former, JMESPath for the latter. There's no reason why the remote service couldn't accept a jq filter, or that you couldn't use a JMESPath-based executable.

like image 51
chepner Avatar answered Sep 30 '22 17:09

chepner