Implement all the examples from jq tutorial in jet:
https://stedolan.github.io/jq/tutorial/
In jq
curl 'https://api.github.com/repos/stedolan/jq/commits?per_page=5' | jq '.'
In jet
curl 'https://api.github.com/repos/stedolan/jq/commits?per_page=5' | jet -p
In jq
curl 'https://api.github.com/repos/stedolan/jq/commits?per_page=5' | jq '.[0]'
In jet
curl 'https://api.github.com/repos/stedolan/jq/commits?per_page=5' | jet -i json -o json -f '#(first %)'
or
curl 'https://api.github.com/repos/stedolan/jq/commits?per_page=5' | jet -i json -o json -q 'first'
So that it looks like this:
{
"message": "Merge pull request #162 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161",
"name": "Stephen Dolan"
}
In jq
curl 'https://api.github.com/repos/stedolan/jq/commits?per_page=5' | jq '.[0] | {message: .commit.message, name: .commit.committer.name}'
In jet
curl 'https://api.github.com/repos/stedolan/jq/commits?per_page=5' | \ jet -p -i json -o json -k --query 'first' -f '#(hash-map :message (get-in % [:commit :message]) :name (get-in % [:commit :committer :name]))'
In jq
jq '.[] | {message: .commit.message, name: .commit.committer.name}
In jet
jet -p -i json -o json -k -f '#(map (fn [x] (hash-map :message (get-in x [:commit :message]) :name (get-in x [:commit :committer :name]))) %)'
In jq
jq '[.[] | {message: .commit.message, name: .commit.committer.name, parents: [.parents[].html_url]}]'
In jet
jet -p -i json -o json -k -f \
'#(map
(fn [x]
(hash-map
:message (get-in x [:commit :message])
:name (get-in x [:commit :committer :name])
:parents (mapv :html_url (:parents x)))) %)'
or
jet -p -i json -o json -k -f /tmp/fn.clj
where /tmp/fn.clj contains the function:
#(map
(fn [x]
(hash-map
:message (get-in x [:commit :message])
:name (get-in x [:commit :committer :name])
:parents (mapv :html_url (:parents x)))) %)