Update
In the time since my original response, /r/random has been updated to preserve extensions, so you can also now avoid having to manually process the Location
header:
$ curl http://www.reddit.com/r/random.json
{
"data": {
"after": "t3_1ubf3e",
...
Original response
http://www.reddit.com/r/random results in a redirect to a random subreddit, but does not preserve extensions. At this time, the best way to achieve your goal would be to examine the response for the Location:
header, and then perform a request to the JSON endpoint for that subreddit.
For example, using curl:
$ curl --include http://www.reddit.com/r/random
HTTP/1.1 302 Moved Temporarily
Location: http://www.reddit.com/r/cocktails/
...
reddit says you should checkout the "cocktails" subreddit, so request the JSON data for that subreddit:
$ curl http://www.reddit.com/r/cocktails/.json
{
"data": {
"after": "t3_1ubf3e",
...