Created
November 11, 2012 08:55
-
-
Save b10m/4054207 to your computer and use it in GitHub Desktop.
Pretty printing (JSON/XML) from the commandline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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