Note that JSON_PRETTY_PRINT
was added in PHP 5.4.
Because most developers are not as nice to their API users as you are, I like to use curl and pipe the response (if it's json) through the wonderful jq (http://stedolan.github.io/jq/). It pretty prints json and gives it a nice coloured syntax. It can even get you part of the json result if you specify a path. Example | jq '.results[0]'
gets you the first result from {"results":[...]}
.
Cool, some really nice solutions. I am wondering though, I am not saying using a password is the best idea, but even when using keys, isn't the password to your Amazon account still the weakest link in the case of EC2 instances?
Thanks for the link. But the problem I was trying to solve though was to be able to connect to the instance from any machine without having to cary the .pem file with me all the time. I am not always on my own machine, so I don't want to leave access to the instace open either. I should have mentioned it above. I'll update.
If you know a better solution, please let me know.
I added a shortcut to ST2 that gives me a pretty printing line, similar to what your function does, that also includes file name, and line number so I can easily find all of them when I am done debugging. See http://coderwall.com/p/3fa_pw
Really cool you shared how you got to your solution. Thanks!
@drywheattoast. I agree. But the conversation in the comments is interesting. I admit I was wrong though, so I'll leave this here:
For anyone reading this in the future: DON'T DO THIS. IT IS A BAD IDEA. I thought it was a good one, because it made my life simpler, but people wiser than me have taught me otherwise. Please read all the comments above. If you still want to continue, you're on your own.