4 ms·
I like how it allows you to abbreviate JSON, but the API I use most frequently puts objects within objects, and the readability rapidly goes down to "curl" leve
by theonemind 10y ago
I like how it allows you to abbreviate JSON, but the API I use most frequently puts objects within objects, and the readability rapidly goes down to "curl" level for this case. As far as I know, this is still as concisely as you can write this with httpie. Most of the things that don't involve putting an object in an object in json seem to write out much more cleanly in httpie. In this case, you still mostly end up just writing the json:
http --json POST https://iad.servers.api.rackspacecloud.com/v2/123456/servers \
'X-Auth-Token':'authtoken' \
'Content-Type':'application/json' \
server:='{
"metadata": {
"metadatagoes": "here"
},
"imageRef": "b21af3ef-1a1e-46b5-98ef-bb0c81b25292",
"networks": [
{
"uuid": "00000000-0000-0000-0000-000000000000"
},
{
"uuid": "11111111-1111-1111-1111-111111111111"
}
],
"flavorRef": "general1-1",
"name": "servername",
"OS-DCF:diskConfig": "MANUAL"
}'
- rdtsc 10y agoYou know, I wonder (and perhaps this is already implemented and I just haven't heard of it) if that could be specified by auto-expanding paths: server.metadata.metadatagoes+="here" server.imageRef+="..." server.networks+='[...]' ... Yeah not sure about arrays...
- ak217 10y agoMaybe that sort of stuff is best left to jq, and httpie could focus on interoperability with jq.
- deleted 10y ago[deleted]
- rdtsc 10y agohttpie can pipe data from stdin. So stuff like this might work? jq -n '.a.b.c = "x"' | http <url>
- jkbr 10y agoThis feature is planned: https://github.com/jkbrzt/httpie/issues/78 https://github.com/jkbrzt/httpie/issues/78
- rdtsc 10y agoThat's awesome! Thanks