I’m not a huge fan of learning another weird DSL for working with json – I can barely keep enough of jq in my head. There’s basically a zero percent chance I’ll be able to write things like --jp ":list Monday, Tuesday, Wednesday, Thursday" without looking them up the once in a blue moon that I need them.
--jp ":list Monday, Tuesday, Wednesday, Thursday"
This is one of my favorite things working in xonsh, I can do all my JSON. Using obvious python notation and have it just work with curl et al
jq for receiving and curl for sending!
Curl’s JSON is only for generating the request body, something which isn’t easy to do with jq (right?)
jq can manipulate data. I’d rather just one tool.
Exciting to see builtin JSON support on the way, although I’m probably going to stick to xh (like HTTPie but in Rust) as it’s really easy to add JSON data, query parameters, headers, etc.
I had just learned about HTTPie, but was bummed to read it’s Python based.
Figured there’s a Rust alternative.
a) having an option to just push to stdout instead of forming a request would allow inspection + iteration more easily as well as making it generally more useful
b) having a seperate tool which only wrote to stdout seems almost nicer. Call it ‘qj’ as the opposite of ‘jq’, and you then have:
qj | curl | jq
with the curl command using the “read json from stdin, set headers approprirately” option outlined in the doc.
The article reference jo, which seems to be what you want.
Thank you, I missed the reference.
Thank you, this is great!
Ah OK so this is really a tool to make handling JSON encoding the right way in HTTP requests easier, right? I know I’ve gotten it wrong a bunch myself :)
I wouldn’t want to learn a new language. But I do think it’s worth allowing JSON5 as input instead of JSON. Especially since JSON5 is a superset, so there’s no incompatibility. Using JSON5 makes sense for the command line to alleviate the amount of escaped double-quotes.
This doesn’t take JSON as input! It emits JSON (and, as such, of course shouldn’t emit a superset).
See also: https://github.com/curl/curl/wiki/JSON