Skip to content

Instantly share code, notes, and snippets.

@b10m
Created November 11, 2012 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b10m/4054207 to your computer and use it in GitHub Desktop.
Save b10m/4054207 to your computer and use it in GitHub Desktop.
Pretty printing (JSON/XML) from the commandline
menno@samael:~$ curl 'https://api.linode.com/?api_key=abc123&api_action=test.echo&api_responseFormat=json'
{"ERRORARRAY":[{"ERRORCODE":4,"ERRORMESSAGE":"Authentication failed"}],"DATA":{},"ACTION":"test.echo"}
menno@samael:~$ curl -s 'https://api.linode.com/?api_key=abc123&api_action=test.echo&api_responseFormat=json' | python -mjson.tool
{
"ACTION": "test.echo",
"DATA": {},
"ERRORARRAY": [
{
"ERRORCODE": 4,
"ERRORMESSAGE": "Authentication failed"
}
]
}
menno@samael:~$ curl -s 'https://api.linode.com/?api_key=abc123&api_action=test.echo&foo=bar&api_responseFormat=wddx'
<wddxPacket version='1.0'><header/><data><struct><var name='ERRORARRAY'><array length='1'><struct><var name='ERRORCODE'><string>4</string></var><var name='ERRORMESSAGE'><string>Authentication failed</string></var></struct></array></var><var name='DATA'><struct></struct></var><var name='ACTION'><string>test.echo</string></var></struct></data></wddxPacket>
menno@samael:~$ curl -s 'https://api.linode.com/?api_key=abc123&api_action=test.echo&foo=bar&api_responseFormat=wddx' | xmllint --format -
<?xml version="1.0"?>
<wddxPacket version="1.0">
<header/>
<data>
<struct>
<var name="ERRORARRAY">
<array length="1">
<struct>
<var name="ERRORCODE">
<string>4</string>
</var>
<var name="ERRORMESSAGE">
<string>Authentication failed</string>
</var>
</struct>
</array>
</var>
<var name="DATA">
<struct/>
</var>
<var name="ACTION">
<string>test.echo</string>
</var>
</struct>
</data>
</wddxPacket>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment